晚郎
晚郎
  • 发布:2022-08-09 16:27
  • 更新:2023-06-04 13:59
  • 阅读:874

uniapp https 双向认证报错怎么解决

分类:uni-app

第一步:证书文件都放在static目录下面了,按照 configMTLS 官方文档调用,返回success

初始化的时候加载configMTLS

uni.configMTLS({  
                certificates: [  
                    {  
                        host: 'https://vuecc.top',  
                        client: '/static/cert/client.p12',  
                        clientPassword: '123456',  
                        server: [`/static/server.cer`]  
                    }  
                ],  
                success ({ code }) {  
lineNo:96                   console.log('证书装载成功code', code)  
                },  
                fail (e) {  
                    console.log('证书配置失败')  
                },  
                complete () {  
                    console.log('证书配置完成')  
                }  
})

返回结果:
···
证书装载成功code, [Number] 0 at pages/downLoad/downLoad.vue:96
···
第二步骤

gotoVuecctop: function() {  
                var that = this  
                uni.request({  
                    url: 'https://vuecc.top',  
                    method: 'get',  
                    sslVerify: true,  
                    success: (res) => {  
                        console.log('success === ' + JSON.stringify(res))  
                        that.requestResult = res  
                    },  
                    fail: (res) => {  
                        console.log('GG fail === ' + JSON.stringify(res))  
                        that.requestResult = res  
                    }  
                })  
            },

返回结果:

{  
    "errMsg": "request:fail abort statusCode:-1 java.security.cert.CertPathValidatorException: Trust anchor for certification path not found."  
}  
2022-08-09 16:27 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com

解决了么

要回复问题请先登录注册