【问题标题】:How to use springdoc-openapi-maven-plugin with HTTPS如何通过 HTTPS 使用 springdoc-openapi-maven-plugin
【发布时间】:2020-12-07 17:44:05
【问题描述】:

我有一个 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>

【问题讨论】:

    标签: spring-boot maven openapi springdoc


    【解决方案1】:

    这与您的本地 SSL 配置有关。以下是一些提示:

    • 确保您已将证书导入到您的 JDK 信任库。

    • JDK 信任库应该与您的 maven 使用的相同。

    • 在你的 CN 上,确保你声明了 localhost。

    • 运行 maven 命令时不要忘记添加:

      -Djavax.net.ssl.trustStore=/path/to/my-file.jks -Djavax.net.ssl.trustStorePassword=my-pass

    【讨论】:

    • 添加 -Djavax.net.ssl.trustStore=/path/to/my-file.jks -Djavax.net.ssl.trustStorePassword=my-pass 解决了我的问题,谢谢!
    猜你喜欢
    • 2021-10-17
    • 2021-11-09
    • 2023-03-04
    • 2021-10-14
    • 2021-08-08
    • 2022-12-13
    • 1970-01-01
    • 2022-09-30
    • 1970-01-01
    相关资源
    最近更新 更多