Problems using Maven and SSL behind a proxy
When attempting to use Maven behind a corporate firewall, it is necessary to configure proxy settings. However, after correctly configuring these settings, it is possible to encounter an error involving an SSL certificate and difficulties downloading from the Maven repository. The error "SunCertPathBuilderException: unable to find valid certification path to requested target" may appear.
The solution lies in resolving the proxy issue. To do so, follow these steps:
Import the Certificate: Open a command prompt and type the following command, substituting your own paths:
keytool -import -file C:\temp\mavenCert.cer -keystore C:\temp\mavenKeystore
Configure Maven: Run the Maven command again, this time with the parameter -Djavax.net.ssl.trustStore=C:tempmavenKeystore:
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -Djavax.net.ssl.trustStore=C:\temp\mavenKeystore
Optional Step:
To avoid having to repeat these steps in the future, you can set the MAVEN_OPTS environment variable. For more information on this variable, refer to the documentation.
The above is the detailed content of How to Solve 'SunCertPathBuilderException: unable to find valid certification path to requested target' When Using Maven Behind a Proxy?. For more information, please follow other related articles on the PHP Chinese website!