Java 如何使用证书(root->;ca->;my)确认GET请求
我需要发送GET请求并用证书(my)确认它(身份验证)。证书具有此链(root->ca->my)。 如何使用Reformation2库来实现这一点 为了愤怒 1) 握手已建立,但未进行身份验证,返回错误302(无其他消息) 2) 有一个cUrl库,据我所知,有一个CURLOPT_SSLCERT方法,您可以将证书放入其中 connectionSpec初始化:Java 如何使用证书(root->;ca->;my)确认GET请求,java,ssl,retrofit,retrofit2,tls1.2,Java,Ssl,Retrofit,Retrofit2,Tls1.2,我需要发送GET请求并用证书(my)确认它(身份验证)。证书具有此链(root->ca->my)。 如何使用Reformation2库来实现这一点 为了愤怒 1) 握手已建立,但未进行身份验证,返回错误302(无其他消息) 2) 有一个cUrl库,据我所知,有一个CURLOPT_SSLCERT方法,您可以将证书放入其中 connectionSpec初始化: connectionSettings = new TlsConnectionSettings(keyStoreProvider.getKey
connectionSettings = new TlsConnectionSettings(keyStoreProvider.getKeyStore());
public void init(String baseUrl, TlsConnectionSettings connectionSpec) {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder client = new OkHttpClient.Builder()
.addInterceptor(interceptor);
if (connectionSpec != null) {
client
.connectionSpecs( Collections.singletonList(connectionSpec.getSpec()))
.sslSocketFactory(connectionSpec.getSocketFactory(), connectionSpec.getTrustedManager())
.connectTimeout(40, TimeUnit.SECONDS)
.readTimeout(40,TimeUnit.SECONDS).build();
}
retrofit = new Retrofit.Builder()
.baseUrl("https://" + baseUrl)
.client(client.build())
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build();
}
__
改装客户端初始化:
connectionSettings = new TlsConnectionSettings(keyStoreProvider.getKeyStore());
public void init(String baseUrl, TlsConnectionSettings connectionSpec) {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder client = new OkHttpClient.Builder()
.addInterceptor(interceptor);
if (connectionSpec != null) {
client
.connectionSpecs( Collections.singletonList(connectionSpec.getSpec()))
.sslSocketFactory(connectionSpec.getSocketFactory(), connectionSpec.getTrustedManager())
.connectTimeout(40, TimeUnit.SECONDS)
.readTimeout(40,TimeUnit.SECONDS).build();
}
retrofit = new Retrofit.Builder()
.baseUrl("https://" + baseUrl)
.client(client.build())
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build();
}