我需要使用证书进行证书固定,但是我不知道从哪里开始请求和处理响应...任何人都可以为此建议逐步教程吗?
答案 0 :(得分:0)
我们可以按值设置证书固定。..
OkHttpClient.Builder builder = new OkHttpClient.Builder()
.connectTimeout(65, TimeUnit.SECONDS)
.writeTimeout(1, TimeUnit.MINUTES)
.readTimeout(1, TimeUnit.MINUTES);
用于证书固定的调用方法
public static void addCertificatePinner(OkHttpClient.Builder httpBuilder) {
CertificatePinner.Builder certificatePinnerBuilder = new CertificatePinner.Builder();
certificatePinnerBuilder.add("url", certificatePublicKey);// certificatePublicKey as String key
CertificatePinner certificatePinner = certificatePinnerBuilder.build();
httpBuilder.certificatePinner(certificatePinner);
}