如何解决证书链错误?现在用代码

时间:2015-12-10 18:46:50

标签: java keystore

我正在尝试使用供应商提供的一组Web服务。我有Java应用程序代码,用尽了使用javax.xml中的类到以下的NetBeans:

  1. 根据其URL和QName
  2. 创建一个新的Service对象
  3. 基于该服务对象创建一个Dispatch对象
  4. 在Dispatch对象
  5. 的请求上下文中放置一个BindingProvider(无论是什么)
  6. 调用dispatch对象。

    public static void main(String[] args) {
        try
        {
    final Service service 
      = Service.create(new URL("blahblahblah.wsdl"),
                        new QName("http://schemas.microsoft.com/ws/2008/06/identity/securitytokenservice", 
                        "SecurityTokenService")
                       );
    
    final Dispatch dispatch 
      = service.createDispatch(new QName("http://schemas.microsoft.com/ws/2008/06/identity/securitytokenservice", "CustomBinding_IWSTrust13Sync"), 
                                JAXBContext.newInstance("org.oasis_open.docs.ws_sx.ws_trust._200512"), 
                                Mode.PAYLOAD, 
                                new AddressingFeature()
                              );
    
    final BindingProvider provider = (BindingProvider) dispatch;
    
    final Map requestContext = provider.getRequestContext();
    
    requestContext.put(BindingProvider.SOAPACTION_URI_PROPERTY, "http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue");
    
    final RequestSecurityTokenType request = new RequestSecurityTokenType();
    
    dispatch.invoke(new JAXBElement<RequestSecurityTokenType>
                          (new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512", "RequestSecurityToken"), 
                            RequestSecurityTokenType.class, 
                            request)
                          );
        }
        catch (Exception e) { e.printStackTrace(); }
    }
    
  7. 此时,我在sysout中遇到错误:表格中有十几个警告:

    [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector] selectAlternatives 警告:WSP0075:策略断言“{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702} Trust13”被评估为“未知”;每条此类消息都有不同的值代替“Trust13”。

    然后我得到

      

    com.sun.xml.internal.ws.client.ClientTransportException:HTTP   传输错误:javax.net.ssl.SSLHandshakeException:   sun.security.validator.ValidatorException:PKIX路径构建失败:   sun.security.provider.certpath.SunCertPathBuilderException:无法   找到所请求目标的有效证书路径

    供应商向我提供了许多文件;其中三个似乎与安全有关。我在我知道的两个密钥库中导入了“.cer”文件和“.p7b”文件(“\ users \ rcook.keystore”和“%JAVA_HOME%\ jre \ lib \ security \ cacerts”)。

    有第三个文件,哪个图标可能意味着它与安全相关,但是当我使用KeyStore Explorer(5.1.1)尝试打开它时,KSE说它无法读取。

    我已经在我的名单上找到了一本关于此的书并了解更多信息;与此同时,我在哪里可以找到这个特定程序错误的解决方案?

0 个答案:

没有答案
相关问题