go to  ForumEasy.com   
JavaPro  
 
 
   Home  |  MyForum  |  FAQ  |  Archive    You are not logged in. [Login] or [Register]  
Forum Home » Secure Socket Connectivity (SSL/TLS) » TLSv1.3 Only
Email To Friend  |   Set Alert To This Topic Rewarding Points Availabe: 0 (What's this) New Topic  |   Post Reply
Author Topic: TLSv1.3 Only
X509
member
offline   
 
posts: 33
joined: 05/01/2007
from: MS
  posted on: 10/27/2021 05:48:27 PM    Edit  |   Quote  |   Report 
TLSv1.3 Only
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);
}


 Profile | Reply Points Earned: 0

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