SSL Java Keycerts证书

时间:2015-06-24 18:59:04

标签: java ssl ssl-certificate

好吧,保持代码旧,因为这是在Java 1.4上运行(不要问为什么),这是唯一的选择。我需要在客户端和服务器之间使用Java 1.4加密套接字连接。

客户端和服务器都支持通用协议和密码,如下所示。

我按原样运行代码,客户端失败: IOException javax.net.ssl.SSLException:连接已关闭:javax.net.ssl.SSLHandshakeException:收到致命警报:handshake_failure

服务器失败: IOException javax.net.ssl.SSLHandshakeException:没有共同的密码套件

我还尝试将客户端和服务器的参数设置为SSL3和SSL_RSA_WITH_NULL_SHA密码。我得到了同样的问题。

我想这可能是keytool问题,但你如何签名并连接到自我127.0.0.1

谢谢,

客户代码:

public static void main(String[] args) {
System.setProperty("javax.net.ssl.trustStore","/usr/lib/jvm/java-8-oracle/jre/lib/security/jssecacerts");
     try {
    SocketFactory sf = SSLSocketFactory.getDefault();
    Socket s = sf.createSocket("127.0.0.1", 5000);            
    BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
    PrintWriter pw = new PrintWriter(s.getOutputStream());
    pw.println("some text");
    pw.flush();
    System.out.println(br.readLine());
    s.close();            
} catch (IOException ex) {
    System.out.println("IOException "+ex);
}                           

}

服务器代码:

public class SSLSocketServer extends Thread {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    System.setProperty("javax.net.ssl.trustStore","/usr/lib/jvm/java-8-oracle/jre/lib/security/jssecacerts");
    try {
        ServerSocketFactory ssf = SSLServerSocketFactory.getDefault();
        ServerSocket ss = ssf.createServerSocket(5000);

        System.out.println("Ready...");
        while (true) {
            new SSLSocketServer(ss.accept()).start();
        }
    } catch (IOException ex) {
        System.out.println("IOException "+ex);
    }}




private Socket sock;

public SSLSocketServer(Socket s) {
        sock = s;
}

public void run() {
try {
   System.out.println("In Run");
  BufferedReader br = new BufferedReader(new InputStreamReader(sock.getInputStream()));
  PrintWriter pw = new PrintWriter(sock.getOutputStream());

  String data = br.readLine();
  pw.println(data);
  pw.close();
  sock.close();
} catch (IOException ioe) {
  System.out.println("IOException "+ioe);
}}}

支持客户:

  

支持的协议:   SSLv2Hello,SSLv3,TLSv1,TLSv1.1,TLSv1.2,

     

支持的密码套装:TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,   TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,   TLS_RSA_WITH_AES_256_CBC_SHA256,   TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384,   TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384,   TLS_DHE_RSA_WITH_AES_256_CBC_SHA256,   TLS_DHE_DSS_WITH_AES_256_CBC_SHA256,   TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,   TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,   TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA,   TLS_ECDH_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,   TLS_DHE_DSS_WITH_AES_256_CBC_SHA,   TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,   TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,   TLS_RSA_WITH_AES_128_CBC_SHA256,   TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256,   TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256,   TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,   TLS_DHE_DSS_WITH_AES_128_CBC_SHA256,   TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,   TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA,   TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA,   TLS_ECDH_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,   TLS_DHE_DSS_WITH_AES_128_CBC_SHA,   TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,   TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,   TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,   TLS_RSA_WITH_AES_256_GCM_SHA384,   TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384,   TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384,   TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,   TLS_DHE_DSS_WITH_AES_256_GCM_SHA384,   TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,   TLS_RSA_WITH_AES_128_GCM_SHA256,   TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256,   TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256,   TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,   TLS_DHE_DSS_WITH_AES_128_GCM_SHA256,   TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA,   TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,SSL_RSA_WITH_3DES_EDE_CBC_SHA,   TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA,   TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA,   SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA,SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA,   TLS_ECDHE_ECDSA_WITH_RC4_128_SHA,TLS_ECDHE_RSA_WITH_RC4_128_SHA,   SSL_RSA_WITH_RC4_128_SHA,TLS_ECDH_ECDSA_WITH_RC4_128_SHA,   TLS_ECDH_RSA_WITH_RC4_128_SHA,SSL_RSA_WITH_RC4_128_MD5,   TLS_EMPTY_RENEGOTIATION_INFO_SCSV,   TLS_DH_anon_WITH_AES_256_GCM_SHA384,   TLS_DH_anon_WITH_AES_128_GCM_SHA256,   TLS_DH_anon_WITH_AES_256_CBC_SHA256,   TLS_ECDH_anon_WITH_AES_256_CBC_SHA,TLS_DH_anon_WITH_AES_256_CBC_SHA,   TLS_DH_anon_WITH_AES_128_CBC_SHA256,   TLS_ECDH_anon_WITH_AES_128_CBC_SHA,TLS_DH_anon_WITH_AES_128_CBC_SHA,   TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA,   SSL_DH_anon_WITH_3DES_EDE_CBC_SHA,TLS_ECDH_anon_WITH_RC4_128_SHA,   SSL_DH_anon_WITH_RC4_128_MD5,SSL_RSA_WITH_DES_CBC_SHA,   SSL_DHE_RSA_WITH_DES_CBC_SHA,SSL_DHE_DSS_WITH_DES_CBC_SHA,   SSL_DH_anon_WITH_DES_CBC_SHA,SSL_RSA_EXPORT_WITH_DES40_CBC_SHA,   SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA,   SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA,   SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA,   SSL_RSA_EXPORT_WITH_RC4_40_MD5,SSL_DH_anon_EXPORT_WITH_RC4_40_MD5,   TLS_RSA_WITH_NULL_SHA256,TLS_ECDHE_ECDSA_WITH_NULL_SHA,   TLS_ECDHE_RSA_WITH_NULL_SHA,SSL_RSA_WITH_NULL_SHA,   TLS_ECDH_ECDSA_WITH_NULL_SHA,TLS_ECDH_RSA_WITH_NULL_SHA,   TLS_ECDH_anon_WITH_NULL_SHA,SSL_RSA_WITH_NULL_MD5,   TLS_KRB5_WITH_3DES_EDE_CBC_SHA,TLS_KRB5_WITH_3DES_EDE_CBC_MD5,   TLS_KRB5_WITH_RC4_128_SHA,TLS_KRB5_WITH_RC4_128_MD5,   TLS_KRB5_WITH_DES_CBC_SHA,TLS_KRB5_WITH_DES_CBC_MD5,   TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA,   TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5,TLS_KRB5_EXPORT_WITH_RC4_40_SHA,   TLS_KRB5_EXPORT_WITH_RC4_40_MD5,

     

设置协议:SSLv3,

服务器支持:

  

支持的密码套装:

     

TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384   TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 TLS_RSA_WITH_AES_256_CBC_SHA256   TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384   TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384   TLS_DHE_RSA_WITH_AES_256_CBC_SHA256   TLS_DHE_DSS_WITH_AES_256_CBC_SHA256   TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA   TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA TLS_RSA_WITH_AES_256_CBC_SHA   TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA TLS_ECDH_RSA_WITH_AES_256_CBC_SHA   TLS_DHE_RSA_WITH_AES_256_CBC_SHA TLS_DHE_DSS_WITH_AES_256_CBC_SHA   TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256   TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 TLS_RSA_WITH_AES_128_CBC_SHA256   TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256   TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256   TLS_DHE_RSA_WITH_AES_128_CBC_SHA256   TLS_DHE_DSS_WITH_AES_128_CBC_SHA256   TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA   TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA TLS_RSA_WITH_AES_128_CBC_SHA   TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA TLS_ECDH_RSA_WITH_AES_128_CBC_SHA   TLS_DHE_RSA_WITH_AES_128_CBC_SHA TLS_DHE_DSS_WITH_AES_128_CBC_SHA   TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384   TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256   TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 TLS_RSA_WITH_AES_256_GCM_SHA384   TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384   TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384   TLS_DHE_RSA_WITH_AES_256_GCM_SHA384   TLS_DHE_DSS_WITH_AES_256_GCM_SHA384   TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 TLS_RSA_WITH_AES_128_GCM_SHA256   TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256   TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256   TLS_DHE_RSA_WITH_AES_128_GCM_SHA256   TLS_DHE_DSS_WITH_AES_128_GCM_SHA256   TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA   TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA SSL_RSA_WITH_3DES_EDE_CBC_SHA   TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA   TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA   SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA TLS_ECDHE_ECDSA_WITH_RC4_128_SHA   TLS_ECDHE_RSA_WITH_RC4_128_SHA SSL_RSA_WITH_RC4_128_SHA   TLS_ECDH_ECDSA_WITH_RC4_128_SHA TLS_ECDH_RSA_WITH_RC4_128_SHA   SSL_RSA_WITH_RC4_128_MD5 TLS_EMPTY_RENEGOTIATION_INFO_SCSV   TLS_DH_anon_WITH_AES_256_GCM_SHA384   TLS_DH_anon_WITH_AES_128_GCM_SHA256   TLS_DH_anon_WITH_AES_256_CBC_SHA256 TLS_ECDH_anon_WITH_AES_256_CBC_SHA   TLS_DH_anon_WITH_AES_256_CBC_SHA TLS_DH_anon_WITH_AES_128_CBC_SHA256   TLS_ECDH_anon_WITH_AES_128_CBC_SHA TLS_DH_anon_WITH_AES_128_CBC_SHA   TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA SSL_DH_anon_WITH_3DES_EDE_CBC_SHA   TLS_ECDH_anon_WITH_RC4_128_SHA SSL_DH_anon_WITH_RC4_128_MD5   SSL_RSA_WITH_DES_CBC_SHA SSL_DHE_RSA_WITH_DES_CBC_SHA   SSL_DHE_DSS_WITH_DES_CBC_SHA SSL_DH_anon_WITH_DES_CBC_SHA   SSL_RSA_EXPORT_WITH_DES40_CBC_SHA   SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA   SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA   SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA SSL_RSA_EXPORT_WITH_RC4_40_MD5   SSL_DH_anon_EXPORT_WITH_RC4_40_MD5 TLS_RSA_WITH_NULL_SHA256   TLS_ECDHE_ECDSA_WITH_NULL_SHA TLS_ECDHE_RSA_WITH_NULL_SHA   SSL_RSA_WITH_NULL_SHA TLS_ECDH_ECDSA_WITH_NULL_SHA   TLS_ECDH_RSA_WITH_NULL_SHA TLS_ECDH_anon_WITH_NULL_SHA   SSL_RSA_WITH_NULL_MD5 TLS_KRB5_WITH_3DES_EDE_CBC_SHA   TLS_KRB5_WITH_3DES_EDE_CBC_MD5 TLS_KRB5_WITH_RC4_128_SHA   TLS_KRB5_WITH_RC4_128_MD5 TLS_KRB5_WITH_DES_CBC_SHA   TLS_KRB5_WITH_DES_CBC_MD5 TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA   TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5 TLS_KRB5_EXPORT_WITH_RC4_40_SHA   TLS_KRB5_EXPORT_WITH_RC4_40_MD5

     

支持的协议:SSLv2Hello SSLv3 TLSv1 TLSv1.1 TLSv1.2

     

设置协议:SSLv3

0 个答案:

没有答案