我有一个 spring 项目,其中所有端点都运行 https,这会在尝试运行 mvn verify -Dspring.application.admin.enabled=true -Dspring-boot.run.profiles=dev< 时导致以下错误
。有没有办法指定证书路径?或者使用 spring security 仅使用此端点 http 而不是 https 。
错误:
[ERROR] An error has occurred
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
Pom.xml
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.0.RELEASE</version>
<executions>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>post-integration-test</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<apiDocsUrl>https://localhost:8444/v3/api-docs</apiDocsUrl>
</configuration>
</plugin>
最佳答案
这与您本地的 SSL 配置有关。以下是一些提示:
确保您已将证书导入到 JDK 信任库中。
JDK 信任库应该与您的 maven 使用的相同。
在您的 CN 上,确保声明 localhost。
当你运行maven命令时不要忘记添加:
-Djavax.net.ssl.trustStore=/path/to/my-file.jks -Djavax.net.ssl.trustStorePassword=my-pass
关于spring-boot - 如何通过 HTTPS 使用 springdoc-openapi-maven-plugin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63470321/