Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1576

Bypass Certificate Verification in flutter with https?

$
0
0

I just want to bypass the certificate verification but I het the error that the badCertificateCallback is not defined for client. Do you know how can I make this work?

Thank you.

This is my actual code

http.Client client = http.Client();    HttpClient() {      // Load the PEM certificate file during class initialization      loadCertificate();    }    Future<void> loadCertificate() async {  // Load the certificate asset  ByteData data = await rootBundle.load('assets/certificate.pem');  // Convert the ByteData to a List<int>  List<int> bytes = data.buffer.asUint8List();  // Configure the default HTTP client to use the certificate  SecurityContext securityContext = SecurityContext.defaultContext;  securityContext.setTrustedCertificatesBytes(bytes);  // Set the badCertificateCallback    client.badCertificateCallback = (X509Certificate cert, String host, int port) {      // Always trust the certificate      return true;    };`

Viewing all articles
Browse latest Browse all 1576

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>