HTTPS证书有时会在Android WebView中失败

时间:2016-10-24 20:09:22

标签: android ssl webview https

我在Android中有一个webview。当我从http站点重定向到客户端托管的https站点时,我会出现间歇性的HTTPS / SSL故障。

失败日志:

com.company.myapp  D  AppWebViewClient -> analyzeURL : 1936 : 2016/10/24 5:36:29 : URL: https://client.website.com/ApplicationRegPage/createAccount
com.company.myapp  D  AppWebViewClient -> onReceivedSslError : 1936 : 2016/10/24 5:36:30 : Received SSL Error
com.company.myapp  D  AppWebViewClient -> onReceivedSslError : 1936 : 2016/10/24 5:36:30 : SSL Error::https://client.website.com/ApplicationRegPage/createAccount:: primary error: 3 certificate: Issued to: CN=client.website.com,OU=MIT,O=Client\,
                                   Inc,L=Mounds View,ST=Minnesota,C=US;
com.company.myapp  D  Issued by: CN=Symantec Class 3 Secure Server CA - G4,OU=Symantec Trust Network,O=Symantec Corporation,C=US;
com.company.myapp  D   on URL: https://client.website.com/ApplicationRegPage/createAccount

com.company.myapp  D  AppWebViewClient -> printCertificate : 1936 : 2016/10/24 5:36:30 : Expanding Certificate: Issued to: CN=client.website.com,OU=MIT,O=Client\, Inc,L=Mounds View,ST=Minnesota,C=US;
com.company.myapp  D  Issued by: CN=Symantec Class 3 Secure Server CA - G4,OU=Symantec Trust Network,O=Symantec Corporation,C=US;
com.company.myapp  D  AppWebViewClient -> printCertificate : 1936 : 2016/10/24 5:36:30 : Issued by
com.company.myapp  D  AppWebViewClient -> printDName : 1936 : 2016/10/24 5:36:30 : DName: CN=Symantec Class 3 Secure Server CA - G4,OU=Symantec Trust Network,O=Symantec Corporation,C=US
com.company.myapp  D  AppWebViewClient -> printDName : 1936 : 2016/10/24 5:36:30 : CName: Symantec Class 3 Secure Server CA - G4
com.company.myapp  D  AppWebViewClient -> printDName : 1936 : 2016/10/24 5:36:30 : OName: Symantec Corporation
com.company.myapp  D  AppWebViewClient -> printDName : 1936 : 2016/10/24 5:36:30 : UName: Symantec Trust Network

com.company.myapp  D  AppWebViewClient -> printCertificate : 1936 : 2016/10/24 5:36:30 : ValidNotAfter: Wed May 31 23:59:59 GApp+00:00 2017
com.company.myapp  D  AppWebViewClient -> printCertificate : 1936 : 2016/10/24 5:36:30 : ValidNotBefore: Wed May 04 00:00:00 GApp+00:00 2016

成功记录:

com.company.myapp  D  AppWebViewClient -> analyzeURL : 1665 : 2016/10/24 5:28:44 : URL: https://client.website.com/ApplicationRegPage/createAccount
com.company.myapp  D  AppWebChromeClient -> onConsoleMessage : 1665 : 2016/10/24 5:28:46 : Console Msg: https://client.website.com/ApplicationRegPage/createAccount::179:: Uncaught ReferenceError: dstb is not defined
com.company.myapp  D  AppWebViewClient -> onPageFinished : 1665 : 2016/10/24 5:28:47 : Finished loading: https://client.website.com/ApplicationRegPage/createAccount
com.company.myapp  D  AppWebViewClient -> printCertificate : 1665 : 2016/10/24 5:28:47 : HTTPS SSL Certificate for URL
com.company.myapp  D  AppWebViewClient -> printCertificate : 1665 : 2016/10/24 5:28:47 : URL: https://client.website.com/ApplicationRegPage/createAccount
com.company.myapp  D  AppWebViewClient -> printCertificate : 1665 : 2016/10/24 5:28:47 : Expanding Certificate: Issued to: CN=client.website.com,OU=MIT,O=Client\, Inc,L=Mounds View,ST=Minnesota,C=US;
com.company.myapp  D  Issued by: CN=Symantec Class 3 Secure Server CA - G4,OU=Symantec Trust Network,O=Symantec Corporation,C=US;
com.company.myapp  D  AppWebViewClient -> printCertificate : 1665 : 2016/10/24 5:28:47 : Issued by
com.company.myapp  D  AppWebViewClient -> printDName : 1665 : 2016/10/24 5:28:47 : DName: CN=Symantec Class 3 Secure Server CA - G4,OU=Symantec Trust Network,O=Symantec Corporation,C=US
com.company.myapp  D  AppWebViewClient -> printDName : 1665 : 2016/10/24 5:28:47 : CName: Symantec Class 3 Secure Server CA - G4
com.company.myapp  D  AppWebViewClient -> printDName : 1665 : 2016/10/24 5:28:47 : OName: Symantec Corporation
com.company.myapp  D  AppWebViewClient -> printDName : 1665 : 2016/10/24 5:28:47 : UName: Symantec Trust Network
com.company.myapp  D  AppWebViewClient -> printCertificate : 1665 : 2016/10/24 5:28:47 : ValidNotAfter: Wed May 31 23:59:59 GApp+00:00 2017
com.company.myapp  D  AppWebViewClient -> printCertificate : 1665 : 2016/10/24 5:28:47 : ValidNotBefore: Wed May 04 00:00:00 GApp+00:00 2016

我已经阅读了针对此“主要错误:3证书”的各种“修复程序”,其中涉及Android WebView对象上的各种配置更改。包括我的配置(我已经尝试设置DOM存储)

protected void configureWebView(WebView mWebView) {
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.setWebViewClient(getWebViewClient());
    mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    mWebView.getSettings().setBuiltInZoomControls(true);
    mWebView.getSettings().setDomStorageEnabled(true);
    // Chrome
    mWebView.setWebChromeClient(getWebChromeClient());
}

这些失败是随机的。我已经看到错误发生在今天早上10个网站加载中。不幸的是,我的客户看到它接近50%的时间。我倾向于在初次启动(或新安装的应用程序,或从Android Studio新安装的应用程序更新)中更频繁地看到此错误,但我的客户似乎更随意地看到它。

2 个答案:

答案 0 :(得分:3)

这似乎与Chrome最近的回归有关,主要是WebView。请参阅

https://bugs.chromium.org/p/chromium/issues/detail?id=664177

要解决此问题,您可以升级到M54 Stable WebView。

答案 1 :(得分:0)

几个月前我遇到了Android 6.0 TLS实施的问题,打破了Tyrus 1.12(WebSocket lib)。事实上,Android打破了Tyrus的依赖,那就是Grizzly 2.3.22(HTTP / NIO lib)。问题描述为here。解决方案是Grizzly本身的一种解决方法,以更仔细的方式调用Android TLS库。

Android错误似乎是this one

至于Marshmallow WebView,我建议您自己拦截HTTPS请求并处理TLS握手,而不是将其委托给WebView。你可以使用一个绕过Android bug的TLS库,比如Grizzly 2.3.24或更高版本。