Nativescript ssl 固定问题

Nativescript ssl pining issue

我必须在我的应用程序中启用 ssl pining。所以,我不得不使用 https://github.com/gethuman/nativescript-https 插件。 我已正确遵循实施步骤。但是当我发出 https 请求时,iOS AFNetworking 中的应用程序崩溃 EXC_BAD_Access 错误

Android 应用出现此错误

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

证书文件夹

reference.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" />

进口

import { File, Folder, knownFolders, path } from 'file-system'
import * as Https from 'nativescript-https'

在构造函数中

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 节点 v6.11.5

Android:删除并重新添加 android 平台。干净的构建解决了这个问题 iOS : 降级到 Afnetworking 3.1.0 解决问题