Skip to content

Instantly share code, notes, and snippets.

@bdshadow
Created December 18, 2018 15:39
Show Gist options
  • Save bdshadow/ad64d6f3660422e8ff06572f4bf6e7fd to your computer and use it in GitHub Desktop.
Save bdshadow/ad64d6f3660422e8ff06572f4bf6e7fd to your computer and use it in GitHub Desktop.
CERTIFICATE_VERIFY_FAILED: Hostname mismatch
import 'dart:convert';
import 'dart:io';
void main() {
var url = "https://192.168.39.219:8443/version";
SecurityContext context = SecurityContext();
context.setTrustedCertificates("/home/dbocharo/.minikube/ca.crt");
context.usePrivateKey("/home/dbocharo/.minikube/ca.key");
HttpClient client = new HttpClient(context: context);
client.getUrl(Uri.parse(url))
.then((HttpClientRequest request) => request.close())
.then((HttpClientResponse response) {
response.transform(utf8.decoder).listen((contents) {
print(contents);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment