Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CERTIFICATE_VERIFY_FAILED #101

Closed
Katletos opened this issue May 27, 2024 · 2 comments
Closed

CERTIFICATE_VERIFY_FAILED #101

Katletos opened this issue May 27, 2024 · 2 comments

Comments

@Katletos
Copy link

Is it possible to use library with self signed? Or how I can pass a certificate in StompClient like http client

flutter: HandshakeException: Handshake error in client (OS Error: CERTIFICATE_VERIFY_FAILED: self signed certificate(handshake.cc:393))

final client = await _getSSLPinningClient();
locator.registerSingleton<InterceptedClient>(InterceptedClient.build(
    client: client,
    interceptors: [
        LoggingInterceptor(storage: locator.get<SecureStorage>())
    ]));
@KammererTob
Copy link
Contributor

As far i am aware there is no mechanism provided for this by the libraries i am using (mainly WebSocketChannel). But if this is for local development only you could try to provide a override for bad certificates like this:

class MyHttpOverrides extends HttpOverrides {
  @override
  HttpClient createHttpClient(SecurityContext? context) {
    return super.createHttpClient(context)
      ..badCertificateCallback =
          (X509Certificate cert, String host, int port) => true; // add your localhost detection logic here if you want
  }
}

void main() {
  HttpOverrides.global = MyHttpOverrides();
  runApp(MaterialApp(home: MyApp()));
}

Also see here: dart-lang/sdk#34284

@KammererTob
Copy link
Contributor

I will close this issue due to inactivity. If you still need assistance feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants