gpt4 book ai didi

java - SunCertPathBuilderException => 带有证书的 Maven JAXB2 生成

转载 作者:行者123 更新时间:2023-12-02 13:34:34 27 4
gpt4 key购买 nike

我正在使用 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.

我做错了什么?

最佳答案

抱歉..我自己解决了这个问题:

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

然后:

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

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

关于java - SunCertPathBuilderException => 带有证书的 Maven JAXB2 生成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43068401/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com