我有 okhttp3.OkHttpClient
我使用第2个命令发出rest请求。
interface WebService {
@GET("/httptwo")
public Call<String> executeRequest();
}
//in these 2 methods I initialize server IP, SSLContext, keystore, truststore and all the stuff.
OkHttpClient client = getClient();
Retrofit retrofit = getRetrofit(client);
//make call
WebService service = retrofit.create(WebService.class);
Call<String> call = service.executeRequest();
try {
Response<String> response = call.execute();
String responseBody = response.body();
System.out.println(responseBody);
} catch (Exception e) {
e.printStackTrace();
}
我向我的虚拟服务器发出请求。
@RestController
class SecureServiceController {
@RequestMapping(value = "/httptwo")
public String httpTwoHandler() {
String httpVersion = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest().getProtocol();
System.out.println("http version: " + httpVersion);
return "Hello from " + httpVersion;
}
}
如您所见,我可以检查http协议的版本。但如何检查所使用的tls版本?
1条答案
按热度按时间am46iovg1#
比如说
TlsVersion.TLS_1_2
.看见https://square.github.io/okhttp/4.x/okhttp/okhttp3/-tls-version/