CertPathValidatorException:找不到证书路径的信任锚。在 android 更新 gradle 和 gradle 插件后

CertPathValidatorException: Trust anchor for certification path not found. in android after update gradle and gradle plugin

我尝试通过以下代码检查 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);

我通过将基数 url 更改为:

得到错误
https://example.com:448/

https://subdomain.example.com/

错误是:

CertPathValidatorException: Trust anchor for certification path not found.

请救救我

这意味着证书是为 www.example.com 颁发的,因此不能信任 whatever.example.com - 此服务器需要适当的签名证书