HarmonyOS 鸿蒙Next:Https请求如何忽略证书认证,HttpClient自定义X509TrustManager发生SSL is null
HarmonyOS 鸿蒙Next:Https请求如何忽略证书认证,HttpClient自定义X509TrustManager发生SSL is null
关于HarmonyOS 鸿蒙Next:Https请求如何忽略证书认证,HttpClient自定义X509TrustManager发生SSL is null的问题,您也可以访问:https://www.itying.com/category-93-b0.html 联系官网客服。
使用rcp完美解决问题,可以跳过验证,也可以自定义验证方式:
是的 rcp完美解决问题 我用rcp重写了。
找HarmonyOS工作还需要会Flutter的哦,有需要Flutter教程的可以学学大地老师的教程,很不错,B站免费学的哦:https://www.bilibili.com/video/BV1S4411E7LY/?p=17
目前我的解决办法就是导入服务器的CA证书,目前接口调用成功。
let client = new HttpClient.Builder()
.setConnectTimeout(10, TimeUnit.SECONDS)
.setReadTimeout(10, TimeUnit.SECONDS)
.setWriteTimeout(10, TimeUnit.SECONDS)
.build();
let ca: string = await new Utils().getCA(‘dl.cer’, getContext());
LogUtils.debug(“ca=====”,ca)
let request: Request = new Request.Builder()
.ca(ca)
.url(getConfig().BASEURL + ‘xxxx’)
.post(RequestBody.create(data, new Mime.Builder().contentType(‘application/json’, ‘charset’, ‘utf8’)
.build()
.getMime()))
.build();
client.newCall(request).checkCertificate(new SslCertificateManager())
<button style="position: absolute; padding: 4px 8px 0px; cursor: pointer; top: 8px; right: 8px; font-size: 14px;">复制</button>
export class SslCertificateManager implements X509TrustManager {
checkClientTrusted(data: cert.X509Cert): void {
LogUtils.debug("========checkClientTrusted===========")
}
checkServerTrusted(X509Certificate: cert.X509Cert): void {
LogUtils.debug("========checkServerTrusted===========")
}
}
<button style="position: absolute; padding: 4px 8px 0px; cursor: pointer; top: 8px; right: 8px; font-size: 14px;">复制</button>
请问你这个是@ohos.net.http吗