Last active
July 20, 2020 07:51
-
-
Save rutcreate/03fb27aa44223f9677509dd3efb2928b to your computer and use it in GitHub Desktop.
Make HTTP Request with SSL Client Certificate (PCSK12)
This file contains 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
import 'dart:convert'; | |
import 'dart:io'; | |
Future getToken() async { | |
var context = SecurityContext.defaultContext; | |
var filepath = './file.p12'; | |
var password = ''; | |
context.useCertificateChain(filepath, password: password); | |
context.usePrivateKey(filepath, password: password); | |
HttpClient client = new HttpClient(context: context); | |
var url = 'https://yourdomain.com'; | |
var request = await client.getUrl(Uri.parse(url)); | |
var response = await request.close(); | |
print(response.statusCode); | |
print(response.cookies); | |
response.transform(utf8.decoder).listen((contents) { | |
// print(contents); | |
exit(0); | |
}); | |
} | |
main(List<String> args) { | |
getToken(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment