spring-boot - 如何通过 HTTPS 使用 springdoc-openapi-maven-plugin
问题描述
我有一个 spring 项目,其中所有端点都在运行 https ,这在尝试运行时会导致以下错误mvn verify -Dspring.application.admin.enabled=true -Dspring-boot.run.profiles=dev
。有没有办法指定证书路径?或仅使用弹簧安全性使此端点 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
推荐阅读
- rust - 如何为 Rust 设置 makeprg?
- azure - 在 Azure 应用服务上运行的 ASP.NET Core 3.1 应用针对 1.6 MB json 有效负载引发 EPIPE 错误
- c++ - 定义非常量内联静态成员对编译有什么影响?
- c# - 使用 Response.AddHeader("content-disposition", attachment) 时如何防止跨站点脚本漏洞?
- typescript - 打字稿说属性推送不适用于“位置 [] | Thenable
" - .net-core - 如何使用私人密钥和 rsasha256 算法 (.net) 创建 jwt 签名?
- mysql - 如何在 SQL 模式中正确设计 2 个表?
- python - 如何生成点分隔字符串的子字符串?
- javascript - 使用 vanilla Javascript 构建购物车功能
- intellij-idea - 如何在 Intellij 中重置“如果由 Y 注释,则抑制 X 警告”?