go to  ForumEasy.com   
JavaPro
Home » Archive » Message


[Email To Friend][View in Live Context][prev topic « prev post | next post » next topic]
  TLSv1.3 Only
 
Subject: TLSv1.3 Only
Author: X509
Posted on: 10/27/2021 05:48:27 PM

3 ways to instruct Java application to use TLSv1.3 protocol only:

Way #1: Use SSLContext to set TLS protocol version:

SSLEngine

SSLContext context = SSLContext.getInstance("TLSv1.3");
SSLEngine sslEngine = context.createSSLEngine("www.example.com", 443);


SSLSocket
SSLContext context = SSLContext.getInstance("TLSv1.3");
SSLSocketFactory socketFactory = context.getSocketFactory();
SSLSocket sslSocket = (SSLSocket)socketFactory.createSocket("www.example.com", 443);



Way #2: Use the SSLSocket/SSLEngine.setEnabledProtocols()
if(sslEngine!=null){
    sslEngine.setEnabledProtocols(new String[] {"TLSv1.3"});
} else {
    sslSocket.setEnabledProtocols(new String[] {"TLSv1.3"});
}


Way #3: Use the SSLParameters.setProtocols()

sslParameters.setProtocols(new String[] {"TLSv1.3"});
if(sslEngine!=null){
    sslEngine.setSSLParameters(sslParameters);
} else {
    sslSocket.setSSLParameters(sslParameters);
}





References:

 


 
Powered by ForumEasy © 2002-2022, All Rights Reserved. | Privacy Policy | Terms of Use
 
Get your own forum today. It's easy and free.