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;
};`
2
Answers
Try using the .. cascade operator:
This is what I use for configure_nonweb.dart
In my main() function I call:
overRideHttps();
To import the file, I look to see if I’m using the web or not:
in file unsupported.dart put: