0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

javax.net.ssl.SSLHandshakeException: PKIX path building failed: VPN環境下でJavaのビルドが失敗する原因と解決方法

0
Posted at

起きている事象

会社で自分が趣味で開発したツールを配布しようと思い、VPN環境下でビルドすると証明書検証に失敗する事象が発生した。

./gradlew shadowJar
Downloading https://services.gradle.org/distributions/gradle-8.7-bin.zip
javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

環境

  • ホストOS: Windows 11 Pro
  • WSL2 in Ubuntu 22.04 LTS

解決方法

VPNクライアントがTLS Inspectionに使用しているルート証明書をJavaのcacertsにimportすれば直る。

ルート証明書を見つけてExportする

  1. Win + r --> certlm.msc
  2. 信頼されたルート証明書 --> 証明書 からVPNのルート証明書を探してexportする

exportした証明書ををJavaのcacertsにimportする

自分はNix Flakeを使っているため、以下のコマンドでうまくいったが、ビルドに使用しているJavaのcacertsにimportする必要があるので適宜書き換えること。

sudo keytool -import -trustcacerts \
  -alias <お好きなエイリアス名> \
  -file <exportした.cer> \
  -keystore "$(dirname $(readlink -f $(which java)))/../lib/security/cacerts"

これで再度ビルドしたら成功した。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?