How to disable SSLv2 socket protocol in axis

回眸只為那壹抹淺笑 提交于 2019-12-08 07:48:56

问题


I have a problem with consuming a web service using axis.This happen because axis sent a SSLv2 ClientHello and the server that offer the webservice does not support the SSLv2 protocol. To fix this i have to disable this protocol. The code for disable it in Java is :

SocketFactory socketFactory = SSLSocketFactory.getDefault();
SSLSocket socket = (SSLSocket) socketFactory.createSocket(hostname, port);
socket.setEnabledProtocols(new String[] {"SSLv3", "TLSv1"});

I refer to these link. Now, the problem is how can I disable this protocol when I am using axis for consuming the webservice?


回答1:


If you're using Axis 2, you should be able to configure an Apache HttpClient 3.x SecureProtocolSocketFactory (see the Axis 2 documentation on the subject). You should be able to set the enabled protocols in createSocket before returning the socket. (You might also be interested in this question.)

For Axis 1, you should be able to set the axis.socketSecureFactory property to your own class name implementing an Axis SecureSocketFactory and configure the socket in the same way there.




回答2:


For Axis 1:

  1. Create your custom MySocketFactory which extends SecureScoketFatory.

    String[] protocols = { "TLSv1" };//provide the list of protocols which you        want to enable
    ((SSLSocket) sslSocket).setEnabledProtocols(protocols);
    
  2. Then at your web service client level provide the System property like below.

    System.setProperty("axis.socketSecureFactory", "com.custom.MySocketFactory");
    


来源:https://stackoverflow.com/questions/9128026/how-to-disable-sslv2-socket-protocol-in-axis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!