IOS处理:
在appDelegate.m文件中添加以下代码:
@implementation NSURLRequest(DataController)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
{
return YES;
}
@end
Android处理:
1、如果没有使用crosswalk
修改 org.apache.cordova.engine.SystemWebViewClient.java文件中onReceivedSslError()方法为如下:
/**
* Notify the host application that an SSL error occurred while loading a resource.
* The host application must call either handler.cancel() or handler.proceed().
* Note that the decision may be retained for use in response to future SSL errors.
* The default behavior is to cancel the load.
*
* @param view The WebView that is initiating the callback.
* @param handler An SslErrorHandler object that will handle the user's response.
* @param error The SSL error object.
*/
@TargetApi(8)
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
2、如果使用crosswalk
a、反编译、修改SslUtil.class,屏蔽// case -200:
SslUtil.class位于org\xwalk\core\internal\下,jar包名可能不一样,找到自己的crosswalk jar包
SslUtil.class下载地址:
1.7jdk编译https://download.csdn.net/download/myfmyfmyfmyf/10934561
1.8jdk编译https://download.csdn.net/download/myfmyfmyfmyf/10934553
b、修改onReceivedSslError方法,将其改为:
@Override
public void onReceivedSslError(XWalkView view, ValueCallbackcallback, SslError error) {
callback.onReceiveValue(true);
}
参考转载自:
https://blog.csdn.net/fxp850899969/article/details/56485447
https://blog.csdn.net/Ruomiz/article/details/81099300