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

Thrown exception is different in iOS and android #42

Closed
abdallah-odeh opened this issue Apr 25, 2023 · 1 comment
Closed

Thrown exception is different in iOS and android #42

abdallah-odeh opened this issue Apr 25, 2023 · 1 comment

Comments

@abdallah-odeh
Copy link

I have a case that should fire the exception CertificateNotVerifiedException, also the logic is handled under that specific exception type

if (err.error is CertificateNotVerifiedException) {
   fireSSLNotMatchException();
   return super.onError(err, handler);
}

in android, this exception is fired as expected, here is the log:

E/flutter ( 7061): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(CONNECTION_NOT_SECURE, Connection is not secure, Fingerprint doesn't match, null)
E/flutter ( 7061): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7)
E/flutter ( 7061): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:315:18)
E/flutter ( 7061): <asynchronous suspension>
E/flutter ( 7061): #2      HttpCertificatePinning.check (package:http_certificate_pinning/src/http_certificate_pinning.dart:35:19)
E/flutter ( 7061): <asynchronous suspension>
E/flutter ( 7061): #3      CertificatePinningInterceptor.onRequest (package:http_certificate_pinning/src/dio/certificate_pinning_interceptor.dart:46:28)
E/flutter ( 7061): <asynchronous suspension>
E/flutter ( 7061): 

Note that here, the exceptionCode is CONNECTION_NOT_SECURE, the returned exception object is CertificateNotVerifiedException

while in iOS, the fired exception is different; here is the log:

flutter:
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(CONNECTION_INSECURE, null, null, null)
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:315:18)
<asynchronous suspension>
#2      HttpCertificatePinning.check (package:http_certificate_pinning/src/http_certificate_pinning.dart:35:19)
<asynchronous suspension>
#3      CertificatePinningInterceptor.onRequest (package:http_certificate_pinning/src/dio/certificate_pinning_interceptor.dart:46:28)
<asynchronous suspension>

the exceptionCode here is CONNECTION_INSECURE, also the returned exception object is CertificateCouldNotBeVerifiedException

so I believe that these should be unified.

@diefferson
Copy link
Owner

Thanks for this observation, exception unified on release 2.1.1

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