ios报错

在AppDelegate.m文件在最后加入(在@end后面加空行):

@implementation NSURLRequest(DataController) + (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host {

   return YES;
} @end

android没出错,出错可以这么解决

main.java,友盟继承的可以不用看:
[java] view plaincopy在CODE上查看代码片派生到我的代码片
public class main extends CordovaActivity
{ @Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
UmengUpdateAgent.setUpdateOnlyWifi(false);
UmengUpdateAgent.update(this);
super.init();
// Set by <content src="index.html" /> in config.xml
super.loadUrl(Config.getStartUrl()); //super.loadUrl("file:///android_asset/www/index.html")
} @Override
protected CordovaWebViewClient makeWebViewClient(CordovaWebView webView) {
// TODO Auto-generated method stub
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
return new SSLAcceptingCordovaWebViewClient(this, webView);
} else {
return new SSLAcceptingIceCreamCordovaWebViewClient(this, webView);
}
}
} SSLAcceptingCordovaWebViewClient:
[java] view plaincopy在CODE上查看代码片派生到我的代码片
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.CordovaWebViewClient;
import org.apache.cordova.DroidGap; import android.net.http.SslError;
import android.webkit.SslErrorHandler;
import android.webkit.WebView; public class SSLAcceptingCordovaWebViewClient extends CordovaWebViewClient{ public SSLAcceptingCordovaWebViewClient(CordovaInterface cordova, CordovaWebView view) {
super(cordova, view);
// TODO Auto-generated constructor stub
} @Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
// testing against getPrimaryError() or hasErrors() will fail on Honeycomb or older.
// You might check for something different, such as specific info in the certificate,
//if (error.getPrimaryError() == SslError.SSL_IDMISMATCH) {
handler.proceed();
//} else {
// super.onReceivedSslError(view, handler, error);
//}
}
} SSLAcceptingIceCreamCordovaWebViewClient.java,名字有点长,网上参考下来的,也懒得去改了:
[java] view plaincopy在CODE上查看代码片派生到我的代码片
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.IceCreamCordovaWebViewClient; import android.net.http.SslError;
import android.webkit.SslErrorHandler;
import android.webkit.WebView; public class SSLAcceptingIceCreamCordovaWebViewClient extends IceCreamCordovaWebViewClient {
public SSLAcceptingIceCreamCordovaWebViewClient(CordovaInterface cordova, CordovaWebView view) {
super(cordova, view);
} @Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
}

phonegap 解决https访问问题的更多相关文章

  1. Jdk1.6 HTTPS访问问题解决办法

    真是艹蛋的一次经历,jdk6上面去访问别人的https,还好有百度搞定了问题.现在写下随笔,记录下; 首先要自己重写SSLSocketFactory这个类, 下面是自己重写的这个类:TLSSocket ...

  2. nginx使用ssl模块配置支持HTTPS访问【解决ssl错误】

    默认情况下ssl模块并未被安装,如果要使用该模块则需要在编译nginx时指定–with-http_ssl_module参数. 需求:做一个网站域名为 www.localhost.cn 要求通过http ...

  3. PHP curl https访问问题

    PHP curl https访问问题,原代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 /* @String url URL地址  * @Array data P ...

  4. 阿里云Ubuntu 14.04 + Nginx + let's encrypt 搭建https访问

    参考页面: https://certbot.eff.org/#ubuntutrusty-nginx http://bbs.qcloud.com/thread-12059-1-1.html http:/ ...

  5. CentOS搭建svn服务器支持https访问

    在CentOS6.3 64位机器上配置SVN服务器,并设置只允许HTTPS连接,可以配置多个repos源,每个源都拥有自己的组和成员,用于权限控制. 安装相关软件 Apache yum install ...

  6. Chrome以https访问gitlab的问题:Your connection is not private

    在Chrome中以https访问自己搭建的gitlab站点时经常出现下面的错误: Attackers might be trying to steal your information from xx ...

  7. 项目通过https访问的tomcat相关配置

    开发项目已经完成,那么就是要部署项目到服务器上面.我最近把刚完成的项目部署到服务器上面,内网通过http协议进行访问一切正常,但是测试外网通过https协议进行访问的时候就出现了一些js文档找不到的b ...

  8. SEO方式之HTTPS 访问优化详解

    SEO到底要不要做HTTPS?HTTPS对SEO的重要性 正方观点 1.HTTPS具有更好的加密性能,避免用户信息泄露: 2.HTTPS复杂的传输方式,降低网站被劫持的风险: 3.搜索引擎已经全面支持 ...

  9. Discuz x3.2利用阿里云cdn处理https访问亲测教程

    第一步配置cdn和https 1.首先去阿里云.腾讯云.七牛云等申请免费https证书 2.虚拟主机是不能直接支持https的,需要cdn处理后才可以,并且端口是80 3.开启cdn加速处理,(买一个 ...

随机推荐

  1. 百度竞价推广URL通配符使用说明

    {keywordid} 被替换为触发该创意的关键词ID(全局唯一ID,不是字面ID),当没有对应的keywordid时,替换为0. {creative} 被替换为所点击的创意ID(全局唯一ID). 2 ...

  2. 发现程序bug思路

    大家有没有遇到过项目,程序出现个bug,但花了好久(真的是a long long time啊)才发现引发这个问题的原因,心想原来就这个原因导致的啊,要是早想到就好了! 其实我们确实的是方法,希望我的抛 ...

  3. hdoj1003--Max Sum

    Problem Description Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum ...

  4. 使用junit单元测试

    使用junit单元测试 一.方法 二.说明 使用这个测试函数或者调试错误非常方便 三.代码实例 后面补

  5. python中的list和array的不同之处 2

    版权声明:本文为博主非原创文章,未经博主允许可以转载.     Python中的list和array的不同之处 python中的list是python的内置数据类型,list中的数据类不必相同的,而a ...

  6. 论文笔记 — MatchNet: Unifying Feature and Metric Learning for Patch-Based Matching

    论文:https://github.com/ei1994/my_reference_library/tree/master/papers 本文的贡献点如下: 1. 提出了一个新的利用深度网络架构基于p ...

  7. Python爬虫之利用正则表达式爬取内涵吧

    首先,我们来看一下,爬虫前基本的知识点概括 一. match()方法: 这个方法会从字符串的开头去匹配(也可以指定开始的位置),如果在开始没有找到,立即返回None,匹配到一个结果,就不再匹配. 我们 ...

  8. gulp插件之-----转化es6代码到es5 取消严格模式 remove "use strict" directive

    Installation npm install babel-plugin-transform-remove-strict-mode && yarn add babel-plugin- ...

  9. 分布式_理论_08_Consistent Hash(一致性哈希算法)

    一.前言 五.参考资料 1.分布式理论(八)—— Consistent Hash(一致性哈希算法)

  10. hdu-2609-How many(串的最小表示)

    题目链接 /* Name:hdu-2609-How many Copyright: Author: Date: 2018/4/24 15:47:49 Description: 串的最小表示 求出每个串 ...