java - CertPathValidatorException:找不到证书路径的信任锚。在 android 中更新 gradle 和 gradle 插件后
问题描述
我尝试通过此代码检查 SSL(并成功运行):
OkHttpClient.Builder httpBuilder = new OkHttpClient.Builder();
CertificatePinner certificatePinner = new CertificatePinner.Builder()
.add("example.com", "sha256/S4AbJNGvyS57nzJwv8sPMUML8VHSqH1vbiBftdPcErI=")
.build();
OkHttpClient client1 = httpBuilder
.certificatePinner(certificatePinner)
.build();
Retrofit retrofit1 = new Retrofit.Builder()
.client(client1)
.baseUrl("https://example.com/").addConverterFactory(GsonConverterFactory.create()).build();
samaniumRestApi2 userClient = retrofit1.create(samaniumRestApi2.class);
Call<Object> call = userClient.maintenanceMode(requestmaintenanceModeCheck);
call.enqueue(xxxxxxxxxxxxx);
我通过将基本网址更改为:
https://example.com:448/
或者
https://subdomain.example.com/
错误是:
CertPathValidatorException: Trust anchor for certification path not found.
请救救我
解决方案
这意味着证书是为www.example.com颁发的,因此无法信任whatever.example.com - 此服务器需要适当的签名证书
推荐阅读
- xamarin - Xamarin - 如何使用 Google Maps API 显示路线
- angular - 使用 ngModel 检索选定的材料单选按钮值时将第一个值设为“未定义”
- node.js - 如果我将数据添加到 Firestore,为什么 Google 反向地理编码会停止工作 - NodeJS
- python - tkinter 中 OtpionMenu 和 ComboBox 的区别
- c# - 如何从字符串中获取包含空终止字符的字节?
- android - 如何在 react-native 应用程序中禁用屏幕截图?
- php - SQLSTATE [42S22]:在 REST Api 中找不到列
- loopbackjs - 环回注销 access_token 是必需的
- r - 如何删除数据框子集中的行
- angular - Angular App out of the box on localhost?