curiousMind
curiousMind

Reputation: 2812

Okhttp support for TLS 1.3

My code is trying to connect one application's REST API which is basically moved from TLS1.2 to TLS 1.3 https://docs.aws.amazon.com/elasticloadbalancing/latest/application/describe-ssl-policies.html

Earlier our code was able to connect to the application but now it is throwing error - javax.net.ssl.SSLException: Received fatal alert: protocol_version

We are calling this API from one of the adapter of ISIM. And the code is using okhttpclient for network call. Below is the existing code -

            SSLContext sslContext = SSLContext.getInstance("TLSv1.2");

OkHttpClient client = new OkHttpClient.Builder()
                    //.connectionSpecs(Collections.singletonList(spec))
                    .connectionSpecs(
                            Arrays.asList(
                            ConnectionSpec.MODERN_TLS,
                            ConnectionSpec.COMPATIBLE_TLS,
                            ConnectionSpec.RESTRICTED_TLS,
                            ConnectionSpec.CLEARTEXT))
                    .sslSocketFactory(sslSocketFactory, trustManager)
                    .hostnameVerifier(new HostnameVerifier() {
                        @Override
                        public boolean verify(String hostname, SSLSession session) {
                            return true;
                        }
                    })
                    .build();

Please help to resolve this. Thanks in advance

Upvotes: 0

Views: 18

Answers (0)

Related Questions