第一步:证书文件都放在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."
}