まえがき
このエラーに3時間ほど時間とられたので備忘として残しておく。
事象
mvn clean
実行時に以下のエラーログが出力される。
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
リモートリポジトリにある依存をダウンロードするときに、有効なSSL証明書がないと怒られる。
対処方法
SSL証明書は$JAVA_HOME/lib/security/cacerts
に作成済だったのだが、こいつを読み取ってくれていなかったのが原因だった。読み取ってくれるように、-Djavax.net.ssl.trustStore
オプションでキーストアを指定する。
mvn clean -Djavax.net.ssl.trustStore=C:\dev\tools\openjdk11\lib\security\cacerts
.mavenrc
に以下のように記載してもよい。
MAVEN_OPTS="-Djavax.net.ssl.trustStore=C:\dev\tools\openjdk11\lib\security\cacerts"
参考