我正在使用带有 OKHTTP3 客户端的 Retrofit 1.9,并且我正在尝试添加认证固定。下面是相关代码:
String hostname = "xxxxxx.xx";
CertificatePinner certificatePinner = new CertificatePinner.Builder()
.add(hostname, "sha1/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=")
.build();
OkHttpClient client = new OkHttpClient.Builder()
.certificatePinner(certificatePinner)
.build();
return new RestAdapter.Builder()
.setRequestInterceptor(request -> {
request.addHeader("CONTENT-TYPE", "application/json");
})
.setEndpoint("https://xxxxxxxxxxxx").
.setClient(new Ok3Client(client))
.build();
不幸的是,它似乎不起作用。我没有
"javax.net.ssl.SSLPeerUnverifiedException: Certificate pinning failure!"
异常,甚至我的主机或 SHA 都不正确。谁能解释为什么?