1

我正在使用 maven-jaxb2 来生成类以调用 Web 服务。

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.12.3</version>
    <configuration>
        <schemaLanguage>WSDL</schemaLanguage>
        <schemas>
            <schema>
                <url>https://my-secured-webservice.com/file?wsdl</url>
            </schema>
        </schemas>
        <generateDirectory>src\main\java</generateDirectory>
        <verbose>true</verbose>
    </configuration>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
</plugin>

wsdl 需要一个正确安装在我的机器上的证书。我可以用我的浏览器访问 wsdl。

我使用 properties-maven-plugin 添加了 2 个属性

<property>
    <name>javax.net.ssl.keyStore</name>
    <value>/path/to/JKS/file.jks</value>
</property>
<property>
    <name>javax.net.ssl.keyStorePassword</name>
    <value>my-super-secret-password</value>
</property>

我通过以下方式创建了我的 jks 文件:

keytool -importkeystore -deststorepass my-super-secret-password -destkeystore /path/to/JKS/file.jks -srckeystore /path/to/file.p12 -srcstoretype PKCS12

当我触发 mvn:generate-sources 时,弹出以下错误:

com.sun.istack.SAXParseException2; IOException thrown when processing "https://my-secured-webservice.com/file?wsdl". Exception: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.

我究竟做错了什么?

4

1 回答 1

1

对不起..我自己解决了这个问题:

我从 de wsdl 位置选择了证书。(我用 chrome 下载了 .crt 文件)

然后:

sudo keytool -importcert -file /path/to/downloaded/certificate.crt -alias myalias -keystore $JAVA_HOME/jre/lib/security/cacerts

所以我将证书导入我的 cacerts..

于 2017-03-28T11:54:58.613 回答