如何强制Axis客户端使用TLSv1.2协议
问题描述:
我们的应用程序与第三方集成最近对其安全级别协议进行了更改。简而言之,My Axis客户端现在应该使用TLSv1.1或TLSv1.2发送呼叫。 我已经看到了这方面的其他职位,有一些好的想法:如何强制Axis客户端使用TLSv1.2协议
使得代码这些变化之后,我又触发了电话, 我使用了一个截图工具来监视发送包,我还是在正在使用的协议是对的TLSv1 SSL层看到的。
我究竟做错了什么?
我这是怎么设置我的新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;
}
}
会很感激任何意见, 感谢。
答
在您的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
答
你也可以改变默认的SSLContext
SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(null, null, null);
SSLContext.setDefault(sslContext);
我有完全一样的问题 - 3'rd党服务器从昨晚开始只接受TLS 1.1或1.2连接,未事先通知。 我使用JDK 6 u 35,Axis 1.4。试图与下面描述的解决方案,但它没有任何区别,tshark仍然说我要走出去与TLSv1:TLSv1 75警报(级别:致命,说明:握手失败) – Sergiu