Last active
March 2, 2023 23:27
-
-
Save koral--/f39a621facc19946e1bc665e299033e1 to your computer and use it in GitHub Desktop.
Dart HTTP client with certificate pinning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final securityContext = SecurityContext(); | |
final certificates = await rootBundle.load('assets/certificates/google.crt'); //1 | |
securityContext.setTrustedCertificatesBytes(certificates.buffer.asUint8List()); //2 | |
final httpClient = HttpClient(context: securityContext); | |
final httpClientRequest = await httpClient.getUrl(Uri.parse('https://google.pl')); | |
final response = await httpClientRequest.close(); | |
print(response.statusCode); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment