How can I edit the list of cipher suite in Java using Bouncy Castle

后端 未结 3 622
庸人自扰
庸人自扰 2020-12-22 03:29

The following code lists the supported cipher suites by Java SE 8:

import java.io.IOException;
import java.net.UnknownHostException;
import java.util.Arrays;         


        
3条回答
  •  囚心锁ツ
    2020-12-22 03:39

    You can't edit the cipher suites directly on factory.

    However you can choose what exact ciphers to support (from the available) on the SSLSocket

    SSLSocketFactory factory = HttpsURLConnection.getDefaultSSLSocketFactory();
    String[] cipherSuites = factory.getSupportedCipherSuites();
    SSLSocket sslSocket = (SSLSocket) factory.createSocket();
    
    // Choose the exact ciphers you need from the available
    String[] filteredCipherSuites = cipherSuites; 
    
    sslSocket.setEnabledCipherSuites(filteredCipherSuites);
    

提交回复
热议问题