Android WebView setCertificate issues SSL problems

前端 未结 4 1336
情书的邮戳
情书的邮戳 2021-02-14 05:45

I have seen a lot of posts and information about SSL errors and I have stumbled upon one myself.

I am trying to access a web page through Android WebView with a GlobalSi

相关标签:
4条回答
  • 2021-02-14 06:18

    I tried to decode the certificate but it does not seem to be valid (actually I tested 2 distinct X509 implementations and both gave me an "incorrect encoding" error).

    Can you give more details on the SSL exception?

    I did not find much information about the setCertificate method. I think this method expects the server certificate. You should ensure that the certificate you decode is the end entity certificate and not a CA certificate.

    0 讨论(0)
  • 2021-02-14 06:21

    If you have a WebClient which overrides the onReceivedSSLError() function and calls the handler.proceed() API, it can solve the certificate issue of error 3, I tested on Android 4.4 and 6.0.

    If you still get an errorCode(-1) in the function onReceivedError(), you need to check the server side implementation sometime, especially when you call the POST method instead of the GET method, because the server may return nothing if there is unexpected POST parameters.

    Good luck.

    0 讨论(0)
  • 2021-02-14 06:31

    The method " setCertificate" is deprecated, so I think that it may not work.I solved a similar problem like yours.If you have your own ssl cacert, you can set networkSecurityConfig .networkSecurityConfig to learn more.

    android:networkSecurityConfig="@xml/network_security_config"
    
    
    <network-security-config>
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" overridePins="true" />
        </trust-anchors>
    </base-config>
    <debug-overrides>
        <trust-anchors>
            <certificates src="system" overridePins="true" />
            <certificates src="user" overridePins="true" />
            <certificates src="@raw/cacert" overridePins="true"></certificates>
        </trust-anchors>
    </debug-overrides>
    </network-security-config>
    

    if you load a url from assets ,you should also set the follow settings. webSetting.setAllowUniversalAccessFromFileURLs(true);

    0 讨论(0)
  • 2021-02-14 06:33

    If you are using InMobi sdk, just update it to latest version and this warning will be fixed. More information here in Sohan's answer

    0 讨论(0)
提交回复
热议问题