Unverified Commit 014a2255 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Nicer error message for TLS errors (#14285)

Also some trivial improvements to style.
parent 671c1101
...@@ -42,6 +42,7 @@ export 'dart:io' ...@@ -42,6 +42,7 @@ export 'dart:io'
// File NO! Use `file_system.dart` // File NO! Use `file_system.dart`
// FileSystemEntity NO! Use `file_system.dart` // FileSystemEntity NO! Use `file_system.dart`
GZIP, GZIP,
HandshakeException,
HttpClient, HttpClient,
HttpClientRequest, HttpClientRequest,
HttpClientResponse, HttpClientResponse,
......
...@@ -37,7 +37,18 @@ Future<List<int>> _attempt(Uri url) async { ...@@ -37,7 +37,18 @@ Future<List<int>> _attempt(Uri url) async {
} else { } else {
httpClient = new HttpClient(); httpClient = new HttpClient();
} }
final HttpClientRequest request = await httpClient.getUrl(url); HttpClientRequest request;
try {
request = await httpClient.getUrl(url);
} on HandshakeException catch (error) {
printTrace(error.toString());
throwToolExit(
'Could not authenticate download server. You may be experiencing a man-in-the-middle attack,\n'
'your network may be compromised, or you may have malware installed on your computer.\n'
'URL: $url',
exitCode: kNetworkProblemExitCode,
);
}
final HttpClientResponse response = await request.close(); final HttpClientResponse response = await request.close();
if (response.statusCode != 200) { if (response.statusCode != 200) {
if (response.statusCode > 0 && response.statusCode < 500) { if (response.statusCode > 0 && response.statusCode < 500) {
......
...@@ -199,10 +199,13 @@ class _FlutterValidator extends DoctorValidator { ...@@ -199,10 +199,13 @@ class _FlutterValidator extends DoctorValidator {
final FlutterVersion version = FlutterVersion.instance; final FlutterVersion version = FlutterVersion.instance;
messages.add(new ValidationMessage('Flutter version ${version.frameworkVersion} at ${Cache.flutterRoot}')); messages.add(new ValidationMessage('Flutter version ${version.frameworkVersion} at ${Cache.flutterRoot}'));
if (Cache.flutterRoot.contains(' ')) if (Cache.flutterRoot.contains(' ')) {
messages.add(new ValidationMessage.error( messages.add(new ValidationMessage.error(
'Flutter SDK install paths with spaces are not yet supported. (https://github.com/flutter/flutter/issues/6577)\n' 'Flutter SDK install paths with spaces are not yet supported. '
'Please move the SDK to a path that does not include spaces.')); '(https://github.com/flutter/flutter/issues/6577)\n'
'Please move the SDK to a path that does not include spaces.'
));
}
messages.add(new ValidationMessage( messages.add(new ValidationMessage(
'Framework revision ${version.frameworkRevisionShort} ' 'Framework revision ${version.frameworkRevisionShort} '
'(${version.frameworkAge}), ${version.frameworkDate}' '(${version.frameworkAge}), ${version.frameworkDate}'
...@@ -215,13 +218,16 @@ class _FlutterValidator extends DoctorValidator { ...@@ -215,13 +218,16 @@ class _FlutterValidator extends DoctorValidator {
// Check that the binaries we downloaded for this platform actually run on it. // Check that the binaries we downloaded for this platform actually run on it.
if (!_genSnapshotRuns(genSnapshotPath)) { if (!_genSnapshotRuns(genSnapshotPath)) {
messages.add(new ValidationMessage.error('Downloaded executables cannot execute ' messages.add(new ValidationMessage.error(
'on host (see https://github.com/flutter/flutter/issues/6207 for more information)')); 'Downloaded executables cannot execute '
'on host (see https://github.com/flutter/flutter/issues/6207 for more information)'
));
valid = ValidationType.partial; valid = ValidationType.partial;
} }
return new ValidationResult(valid, messages, return new ValidationResult(valid, messages,
statusInfo: 'on ${os.name}, locale ${platform.localeName}, channel ${version.channel}'); statusInfo: 'on ${os.name}, locale ${platform.localeName}, channel ${version.channel}'
);
} }
} }
......
...@@ -78,7 +78,7 @@ Future<String> getServiceFromUrl(String url, String rootDir, String serviceName) ...@@ -78,7 +78,7 @@ Future<String> getServiceFromUrl(String url, String rootDir, String serviceName)
if (url.startsWith('android-sdk:') && androidSdk != null) { if (url.startsWith('android-sdk:') && androidSdk != null) {
// It's something shipped in the standard android SDK. // It's something shipped in the standard android SDK.
return url.replaceAll('android-sdk:', '${androidSdk.directory}/'); return url.replaceAll('android-sdk:', '${androidSdk.directory}/');
} else if (url.startsWith('http')) { } else if (url.startsWith('http:') || url.startsWith('https:')) {
// It's a regular file to download. // It's a regular file to download.
return await cache.getThirdPartyFile(url, serviceName); return await cache.getThirdPartyFile(url, serviceName);
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment