转载自:https://blog.csdn.net/fxp850899969/article/details/56485447
IOS上:
在appDelegate.m文件中添加以下代码:
@implementation NSURLRequest(DataController)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
{
return YES;
}
@end
Android上:
修改 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();
}
这篇博客介绍了在iOS和Android平台上如何处理HTTPS请求时遇到的SSL证书错误。在iOS中,通过在appDelegate.m文件中添加代码,允许任何HTTPS证书。在Android方面,需要修改SystemWebViewClient.java文件的onReceivedSslError方法,使其默认接受SSL错误。
&spm=1001.2101.3001.5002&articleId=117586745&d=1&t=3&u=040366438c5a4c6c8193e549b919de61)
1万+

被折叠的 条评论
为什么被折叠?



