Nikhil Agrawal
Nikhil Agrawal

Reputation: 26518

Enabling TLSv1.2 as default in JDK 7

I want to enable TLSv1.2 as default protocol for clients in jdk7. I can see java 7 supports TLS v1.1, 1.2 but the default enabled is TLSv1.0.

I have gone through some post like this one here which says the client application has to specify in startup scripts which security protocol they want to use or the other way to do this is by java programming.

So is there any way out by which I can chnage the default enabled protocol to TLSv1.2 So that no chnage is required in all the running client application.

This is the code which we are using to initiate SSL connection.

//create the SSLContext with your key manager and trust
//manager, and get your socket factory from the context:
SSLContext ctx = SSLContext.getInstance("SSL");
ctx.init(km, tm, null);
SSLSocketFactory factory = ctx.getSocketFactory();

Upvotes: 0

Views: 2290

Answers (1)

Jigar Joshi
Jigar Joshi

Reputation: 240860

Change it to this at the entry point of your Main

    SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
    sslContext.init(null, null, null);
    SSLContext.setDefault(sslContext);

Upvotes: 1

Related Questions