flutter_inappwebview
flutter_inappwebview copied to clipboard
Load client certificate from local storage fails
- [x] I have read the Get Started - Installation section
- [x] I have read and done the Get Started - Setup Android section
- [x] I have read and done the Get Started - Setup iOS section
- [x] I have already searched for the same problem
Environment
Technology | Version |
---|---|
Flutter version | 2.10.1 |
Plugin version | 5.3.2 |
Android version | 11 |
iOS version | |
Xcode version |
Device information: Pixel 4
Description
I try to load a client certificate which is stored in the FlutterSecureStorage:
return InAppWebView(
initialUrlRequest:
URLRequest(url: Uri.parse("<URL>")),
onReceivedClientCertRequest: (InAppWebViewController controller,
URLAuthenticationChallenge challenge) async {
return ClientCertResponse(
certificatePath: certPath,
certificatePassword: certPassword,
action: ClientCertResponseAction.PROCEED);
}
);
Expected behavior: The client certificate is loaded correctly and the website loads as expected.
Current behavior: I get the following exception:
W[/System.err]()( 4107): java.io.FileNotFoundException: flutter_assets//data/user/0/com.example.test/app_flutter/cert/EXAMPLE00004.p12
W[/System.err]()( 4107): at android.content.res.AssetManager.nativeOpenAsset(Native Method)
W[/System.err]()( 4107): at android.content.res.AssetManager.open(AssetManager.java:874)
W[/System.err]()( 4107): at android.content.res.AssetManager.open(AssetManager.java:851)
W[/System.err]()( 4107): at com.pichillilorenzo.flutter_inappwebview.Util.getFileAsset(Util.java:83)
W[/System.err]()( 4107): at com.pichillilorenzo.flutter_inappwebview.Util.loadPrivateKeyAndCertificate(Util.java:139)
W[/System.err]()( 4107): at com.pichillilorenzo.flutter_inappwebview.in_app_webview.InAppWebViewClient$4.success(InAppWebViewClient.java:510)
W[/System.err]()( 4107): at io.flutter.plugin.common.MethodChannel$IncomingResultHandler.reply(MethodChannel.java:239)
W[/System.err]()( 4107): at io.flutter.embedding.engine.dart.DartMessenger.handlePlatformMessageResponse(DartMessenger.java:376)
W[/System.err]()( 4107): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessageResponse(FlutterJNI.java:993)
W[/System.err]()( 4107): at android.os.MessageQueue.nativePollOnce(Native Method)
W[/System.err]()( 4107): at android.os.MessageQueue.next(MessageQueue.java:335)
W[/System.err]()( 4107): at android.os.Looper.loop(Looper.java:183)
W[/System.err]()( 4107): at android.app.ActivityThread.main(ActivityThread.java:7656)
W[/System.err]()( 4107): at java.lang.reflect.Method.invoke(Native Method)
W[/System.err]()( 4107): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
W[/System.err]()( 4107): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
The path (variable certPath) is: /data/user/0/com.example.test/app_flutter/cert/EXAMPLE00004.p12
I don't understand why the file path gets this flutter_assets/
as a prefix? Is it even possible to load the cert from the local storage?
👋 @stedekay
NOTE: This comment is auto-generated.
Are you sure you have already searched for the same problem?
Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!
If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.
In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE]
or ios WKWebView [MY ERROR HERE]
keywords.
Following these steps can save you, me, and other people a lot of time, thanks!
Faced to the same issue on Android and made a PR. https://github.com/pichillilorenzo/flutter_inappwebview/pull/1241
Merged now