How to use springdoc-openapi-maven-plugin with HTTPS

Viewed 945

I have a spring project where all the endpoints are running https which causes the following error when trying to run mvn verify -Dspring.application.admin.enabled=true -Dspring-boot.run.profiles=dev. Is there a way to specify the cert path? Or way to make only this endpoint http instead of https with spring security.

Error:

[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>
1 Answers

This is related to your local SSL configuration. Here are some tips:

  • Make sure you have imported the certificate to your JDK trustore.

  • The JDK trustore should be the same as used by your maven.

  • On your CN, make sure you declare localhost.

  • When you run the maven command don't forget to add:

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

Related