wso2重点商店问题

时间:2017-08-07 11:05:33

标签: wso2

我正在使用wso2 sso version 5.3。我正在配置新的jks密钥来代替wso2carbon.jks并按照步骤进行操作。

  1. 使用自签名证书生成密钥并将密钥复制到文件夹${carbon.home}/repository/resources/security/test2.jks 命令- keytool -genkey -keyalg RSA -alias wso2carbon -keystore keystore.jks -validity 360

  2. 使用新的carbon.xml文件更新了新的test2.jks

    <KeyStore>
        <!-- Keystore file location-->
        <Location>${carbon.home}/repository/resources/security/test2.jks</Location>
        <!-- Keystore type (JKS/PKCS12 etc.)-->
        <Type>JKS</Type>
        <!-- Keystore password-->
        <Password>xxxxxx</Password>
        <!-- Private Key alias-->
        <KeyAlias>wso2carbon</KeyAlias>
        <!-- Private Key password-->
        <KeyPassword>xxxxxx</KeyPassword>
    </KeyStore>
    
  3. 错误讯息:

      

    使用Axis 2库从Java调用时出现异常。 “sun.security.provider.certpath.SunCertPathBuilderException:无法找到所请求目标的有效证书路径”。

    代码段:

    public static void main (String[] args) throws Exception {
    
        final String SERVER_URL = "https://XXXXXXX:9443/services/"; 
        //setting jks key
        System.setProperty("javax.net.ssl.trustStore", "test2.jks"); 
        System.setProperty("javax.net.ssl.trustStorePassword", "XXXXX"); 
        System.setProperty("javax.net.ssl.trustStoreType", "JKS");
    
        try{     
            String cookie = null;
            AuthenticationAdminStub authstub = new AuthenticationAdminStub(SERVER_URL+"AuthenticationAdmin");
    
            // Authenticates as a user having rights to add users. 
            if (authstub.login(XXXXXX, XXXXXX, null)) { 
                cookie = (String) authstub._getServiceClient().getServiceContext().getProperty( 
                        HTTPConstants.COOKIE_STRING); 
                System.out.println("cookie "+cookie);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
    

    堆栈跟踪:

    Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
        at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
        at sun.security.validator.Validator.validate(Unknown Source)
        at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)
        at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
        at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
        ... 42 more
    Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source)
        at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
        at java.security.cert.CertPathBuilder.build(Unknown Source)
        ... 48 more
    

1 个答案:

答案 0 :(得分:0)

尝试为javax.net.ssl.trustStore设置绝对路径。