I have okhttp3.OkHttpClient
and I make REST request using Retrofit2.
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();
}
I make request to my dummy Server.
@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;
}
}
As you can see, I can check version of http protocol. But how can I check version of TLS that was used?