Skip to content

Commit

Permalink
[flutter_tools] handle HandshakeException in httphostvalidator (flutt…
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherfujino authored Jun 1, 2022
1 parent 4e23ed3 commit 99d0f8f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/flutter_tools/lib/src/http_host_validator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class HttpHostValidator extends DoctorValidator {
return _HostValidationResult.fail(host, 'An error occurred while checking the HTTP host: ${e.message}');
} on HttpException catch (e) {
return _HostValidationResult.fail(host, 'An error occurred while checking the HTTP host: ${e.message}');
} on HandshakeException catch (e) {
return _HostValidationResult.fail(host, 'An error occurred while checking the HTTP host: ${e.message}');
} on OSError catch (e) {
return _HostValidationResult.fail(host, 'An error occurred while checking the HTTP host: ${e.message}');
} on FormatException catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,40 @@ void main() {
});
});

testWithoutContext('Does not throw on HandshakeException', () async {
const String handshakeMessage = '''
Handshake error in client (OS Error:
BLOCK_TYPE_IS_NOT_01(../../third_party/boringssl/src/crypto/fipsmodule/rsa/padding.c:108)
PADDING_CHECK_FAILED(../../third_party/boringssl/src/crypto/fipsmodule/rsa/rsa_impl.c:676)
public key routines(../../third_party/boringssl/src/crypto/x509/a_verify.c:108)
CERTIFICATE_VERIFY_FAILED: certificate signature failure(../../third_party/boringssl/src/ssl/handshake.cc:393))
''';
final HttpHostValidator httpHostValidator = HttpHostValidator(
platform: FakePlatform(environment: kTestEnvironment),
featureFlags: TestFeatureFlags(isAndroidEnabled: false),
httpClient: FakeHttpClient.list(<FakeRequest>[
FakeRequest(
Uri.parse(kTestEnvPubHost),
method: HttpMethod.head,
responseError: const HandshakeException(handshakeMessage),
),
FakeRequest(Uri.parse(kTestEnvGCloudHost), method: HttpMethod.head),
]),
);

// Run the validation check and get the results
final ValidationResult result = await httpHostValidator.validate();

expect(
result.messages.first,
isA<ValidationMessage>().having(
(ValidationMessage msg) => msg.message,
'message',
contains(handshakeMessage),
),
);
});

testWithoutContext('Http host validator timeout message includes timeout duration.', () async {
final HttpHostValidator httpHostValidator = HttpHostValidator(
platform: FakePlatform(environment: kTestEnvironment),
Expand Down

0 comments on commit 99d0f8f

Please sign in to comment.