axis2 实现双向SSL 因为密码问题出现NoSuchAlgorithmException

来源:互联网 发布:淘宝开直播一天赚多少 编辑:程序博客网 时间:2024/06/08 05:22

AXIS2实现双向SSL代码:

String endpoint = "https://xxxx/xxx/xxx?wsdl";
    
    RPCServiceClient serviceClient = new RPCServiceClient();
    Options options = serviceClient.getOptions();
    EndpointReference targetEPR = new EndpointReference(endpoint);
    // 禁用http传输分段特性
    options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
    options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, true);
    
    // 设置超时时间
    options.setTimeOutInMilliSeconds(1800000); // 10000 seconds
    
    options.setExceptionToBeThrownOnSOAPFault(false);
    options.setTo(targetEPR);
    System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); 
    Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); 
    System.setProperty("javax.net.ssl.trustStore", "c:\\f5serverkey.truststore");
    System.setProperty("javax.net.ssl.trustStorePassword", "123456");
    
    System.setProperty("javax.net.ssl.keyStore", "c:\\104100000004-P1234.keystore");
    System.setProperty("javax.net.ssl.keyStorePassword", "123456");

出现问题

Exception in thread "main" org.apache.axis2.AxisFault: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl)

原因分析:在客户端根据PFX制作104100000004-P1234.keystore时,pfx 密码是1234,但制作keystore 时将密码修改为123456导致失败

解决方式:1.将pfx密码修改为6位或6位以上(或者重新制作一本)

                    2.制作keystore .并保证和pfx密码一致

0 0
原创粉丝点击