我试图用以下插件对Cordova 5.3.3和Android进行SSL固定:https://github.com/wymsee/cordova-HTTP
当我启用以下函数并完成获取时,它会抛出一个错误500:“请求出现了错误”。(所有测试都是在android设备内部使用检查器完成的)。
window.cordovaHTTP.enableSSLPinning(
true,
function(res) {console.log("SSL pinning: " + res)},
function(err) {console.log("SSL pinning: " + err)}
);
window.cordovaHTTP.get(
"https://95.85.12.4/test.json",
{}, // optional params
{}, // optional headers
function(res) {console.log(res)},
function(err) {console.log(err)}
);如果我接受所有的证书,所有的工作都很好,因为我是重叠的配置钉扎。
window.cordovaHTTP.enableSSLPinning(
true,
function(res) {console.log("SSL pinning: " + res)},
function(err) {console.log("SSL pinning: " + err)}
);
window.cordovaHTTP.acceptAllCerts(
true,
function(res) {console.log('Accept all certs: ' + res)},
function(err) {console.log('Accept all certs: ' + err)}
);
window.cordovaHTTP.get(
"https://95.85.12.4/test.json",
{}, // optional params
{}, // optional headers
function(res) {console.log(res)},
function(err) {console.log(err)}
);我在运行NGINX的服务器上做这个测试。https://95.85.12.4/test.json
我列出了所有的东西(只是为了测试目的)
<!-- Enable all requests, inline styles, and eval() -->
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">我还将AndroidManifest.xml中的可调试变量设置为true。
<application android:debuggable="true">我的证书是用DER格式和.cer扩展自签名的.我检查了openssl的证书是否正确。如果我在我的机器上安装了证书,那么使用浏览器打开服务器URL是没有问题的。
证书位于我的Cordova项目中的/www/证书文件夹中。我还添加了.cer暗示/平台/安卓/资产。
有什么想法吗?
谢谢!
发布于 2016-10-15 20:37:02
此问题与证书格式无关。这是因为IP地址。如果不使用主机名发送请求,则需要使用SubjectAltName (SAN)创建这里证书。你必须把IP地址写成一个alt_name。否则,您将得到“主机名xxx.xxx未验证”错误。
https://stackoverflow.com/questions/33230531
复制相似问题