首页 > 解决方案 > JS:错误 javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:找不到证书路径的信任锚

问题描述

我按照此步骤使用插件nativescripts-https

1:安装:tns plugin add nativescript-https

2:在app.grandle中添加:

 dependencies {
    compile 'com.squareup.okhttp3:okhttp:3.11.0'
  }

3:在tsconfig.json中添加:

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "noEmitHelpers": true,
        "noEmitOnError": false,
        "skipLibCheck": true,
        "skipDefaultLibCheck": true,
        "removeComments": true,
        "pretty": true,
        "lib": [
            "es6",
            "dom",
            "es2016"
        ],

4:在component.ts中添加

  gethttps(){
    Https.disableSSLPinning();
    Https.request({
        url: 'https://xx.xxx.xx.xx:4433/json',
        method: 'GET',
        headers: {
        },
    }).then(function(response) {
        console.log('Https.request response', response)
    }).catch(function(error) {
        console.error('Https.request error', error)
    })
  }

5:在component.html中添加

<StackLayout>
    <Button text="message" (tap)="gethttps()"></Button>
</StackLayout>

当我单击按钮以在控制台中显示此错误时。

JS:nativescript-https > 禁用 SSL 固定 JS:错误 javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:找不到证书路径的信任锚。

拜托,知道如何解决这个问题吗?

太感谢了!

标签: androidhttpsnativescriptokhttp3

解决方案


推荐阅读