Nativescript ssl锁定问题
我必须在我的应用程序中启用ssl pining。所以,我不得不使用插件。 我已经正确地遵循了实施步骤。但当我发出https请求时,iOS应用程序在AFNetworking EXC_BAD_访问错误中崩溃 Android应用程序给出了这个错误Nativescript ssl锁定问题,nativescript,angular2-nativescript,Nativescript,Angular2 Nativescript,我必须在我的应用程序中启用ssl pining。所以,我不得不使用插件。 我已经正确地遵循了实施步骤。但当我发出https请求时,iOS应用程序在AFNetworking EXC_BAD_访问错误中崩溃 Android应用程序给出了这个错误 JS: nativescript-https > Disabled SSL pinning by default JS: nativescript-https > enableSSLPinning error ReferenceError: o
JS: nativescript-https > Disabled SSL pinning by default
JS: nativescript-https > enableSSLPinning error ReferenceError: okhttp3 is not defined
JS: Https.request error ReferenceError: okhttp3 is not defined
证书文件夹
参考d.ts
/// <reference path="./node_modules/tns-core-modules/tns-core-modules.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
在构造函数中
let dir = knownFolders.currentApp().getFolder('certs')
let certificate = dir.getFile('httpbin.org.cer').path
Https.enableSSLPinning({ host: 'httpbin.org', certificate: certificate});
方法
clickLogin(){
Https.request({
url: 'https://httpbin.org/get',
method: 'GET',
headers: {
'content-type': 'application/json'
},
}).then(function(response) {
console.log('Https.request response', response)
}).catch(function(error) {
console.error('Https.request error', error)
})
}
请帮我找出问题所在
tns版本4.0.1
NodeV6.11.5Android:删除并重新添加Android平台。清洁构建解决了这个问题
iOS:降级至Afnetworking 3.1.0解决问题iOS错误似乎与所用POD中的错误有关-请参阅此处了解详细信息
clickLogin(){
Https.request({
url: 'https://httpbin.org/get',
method: 'GET',
headers: {
'content-type': 'application/json'
},
}).then(function(response) {
console.log('Https.request response', response)
}).catch(function(error) {
console.error('Https.request error', error)
})
}