2015-12-09 50 views
7

我們的應用程序與第三方集成最近對其安全級別協議進行了更改。簡而言之,My Axis客戶端現在應該使用TLSv1.1或TLSv1.2發送呼叫。 我已經看到了這方面的其他職位,有一些好的想法:如何強制Axis客戶端使用TLSv1.2協議

  1. here
  2. here

使得代碼這些變化之後,我又觸發了電話, 我使用了一個截圖工具來監視發送包,我還是在正在使用的協議是對的TLSv1 SSL層看到的。

the packet snippet

我究竟做錯了什麼?

我這是怎麼設置我的新SocketSecureFactory:

AxisProperties.setProperty("axis.socketSecureFactory", MyTLSSocketSecureFactory.class.getName()); 

而MyTLSSocketSecureFactory是:

public class MyTLSSocketSecureFactory extends JSSESocketFactory { 
    public MyTLSSocketSecureFactory(Hashtable attributes) { 
     super(attributes); 
    } 

    @Override 
    public Socket create(String host,int port, StringBuffer otherHeaders,BooleanHolder useFullURL) 
       throws Exception{ 
     Socket s = super.create(host, port, otherHeaders, useFullURL); 
     ((SSLSocket)s).setEnabledProtocols(new String[] {"TLSv1.1", "TLSv1.2"}); 
     return s; 
    } 
} 

會很感激任何意見, 感謝。

+0

我有完全一樣的問題 - 3'rd黨服務器從昨晚開始只接受TLS 1.1或1.2連接,未事先通知。 我使用JDK 6 u 35,Axis 1.4。試圖與下面描述的解決方案,但它沒有任何區別,tshark仍然說我要走出去與TLSv1:TLSv1 75警報(級別:致命,說明:握手失敗) – Sergiu

回答

5

在您的MyTLSSocketSecureFactory類中,您需要創建自己的SSLContext實例,然後從上下文中獲取sslFactory。

覆蓋的initFactory()方法,而像有些事情:

initFactory() { 
    SSLContext context = SSLContext.getInstance("TLSv1.2"); 
    context.init(null, null, null); 
    sslFactory = context.getSocketFactory(); 
} 
+0

這很好。只需要更改SSLContext.getInstance(「TSLv1.2」); 「TSL」到TLS .. – Krozen

0

你也可以改變默認的SSLContext

SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); 
    sslContext.init(null, null, null); 
    SSLContext.setDefault(sslContext);