2016-04-26 20 views
0

Wir mussten die SSLV3-Unterstützung entfernen. Also haben wir die activemq-Konfiguration geändert. Wir haben transportConnector hinzugefügt und enabledProtocol = 'TLS1.1, TLS1.2' gesetzt. Damit es auf TLS1.1 oder TLS1.2 unterstützt wird Aber ich bekomme nicht, wie ich Protokoll spezifizieren sollte, wenn ich Verbindung herstelle. Jetzt gibt es mir einen Fehler SSLV2Hello ist deaktiviert. Also meine Frage ist, wie sollte ich Protokollliste beim Erstellen der Verbindung geben. Ich versuchte es SSLSocket aber konnte nicht durch. Kann jemand bitte geben Sie mir Ahnung ..ActiveMQ-Verbindung auf TLS1.2 erstellen

String keyStorePath = "abc.ks"; 
String keyStorePassword = "XYZ"; 
String trustStore = "cks.ts";      
java.lang.System.setProperty("javax.net.ssl.keyStore", keyStorePath); 
java.lang.System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword); 
java.lang.System.setProperty("javax.net.ssl.trustStore", trustStore); 
String connectionURL = 'URL?initialReconnectDelay=10&maxReconnectDelay=10&maxReconnectAttempts=2&jms.watchTopicAdvisories=false&wireFormat.maxInactivityDuration=3600000'; 

ConnectionFactory factory = new ActiveMQSslConnectionFactory(connectionURL); 
Connection connection = factory.createConnection(user, pwd); 
+0

haben sie versucht, "https.protocols" https://blogs.oracle.com/java-platform-group/entry/diagnosing_tls_ssl_and_https Einstellung? – VirtualTroll

Antwort

1

Endlich ist es für mich gearbeitet.

String keyStorePassword = "123456"; 
String configPath = "C:\\ssl\\"; 
String keyStorePath = configPath + "client.ks"; 
KeyStore ks = KeyStore.getInstance("jks"); 
String trustStore = configPath + "trust.ts"; 
java.lang.System.setProperty("javax.net.ssl.trustStore", trustStore); 
java.lang.System.setProperty("javax.net.ssl.trustStorePassword", keyStorePassword); 

      InputStream ksIs = new FileInputStream(keyStorePath); 
      try { 
       ks.load(ksIs, keyStorePassword.toCharArray()); 
      } finally { 
       if (ksIs != null) { 
        ksIs.close(); 
       } 
      } 
      KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); 
      kmf.init(ks, keyStorePassword.toCharArray()); 

      TrustManager[] trustAllCerts = new TrustManager[] { 
        new X509TrustManager() { 
         public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) { 
         } 

         public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) { 
         } 

         public java.security.cert.X509Certificate[] getAcceptedIssuers() { 
          return null; 
         } 
        } 
      }; 

      final SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); 
      ConnectionFactory factory = new ActiveMQSslConnectionFactory(URL); 
      sslContext.init(kmf.getKeyManagers(), trustAllCerts, new SecureRandom());  
      SslContext context = new SslContext(); 
      context.setSSLContext(sslContext); 
      SslContext.setCurrentSslContext(context); 
      Connection connection = factory.createConnection(loginName, pwd); 
      connection.start();   
      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); 
      MessageProducer nonPersistentProducer = session.createProducer(null); 
      session.close(); 
      connection.close();