Skip to content

Instantly share code, notes, and snippets.

@rutcreate
Last active July 20, 2020 07:51
Show Gist options
  • Save rutcreate/03fb27aa44223f9677509dd3efb2928b to your computer and use it in GitHub Desktop.
Save rutcreate/03fb27aa44223f9677509dd3efb2928b to your computer and use it in GitHub Desktop.
Make HTTP Request with SSL Client Certificate (PCSK12)
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