"PKIX Path Building Failed" エラーによって SSL サービスに接続できない
プラットフォームについて: サーバーと Data Center のみ。この記事は、サーバーおよび Data Center プラットフォームのアトラシアン製品にのみ適用されます。
このページの内容はサポート対象外のプラットフォームに関連しています。したがって、アトラシアン サポートではこのページの記載内容のサポートの提供は保証されません。この資料は情報提供のみを目的として提供されています。内容はお客様自身の責任でご利用ください。
問題
Attempting to access applications or websites that are encrypted with SSL (for example HTTPS, LDAPS, IMAPS) throws an exception and the connection is refused. This can happen when attempting to establish a secure connection to any of the following:
- Active Directory サーバー、Jiraのユーザー サーバー、Crowd
- メール サーバー
- Another Atlassian application using Application Links
- Atlassian Marketplace
- Atlassian Migration Service
たとえば、Jira 課題マクロを使用したときに、以下のエラーが UI に表示される。
Error rendering macro: java.io.IOException: Could not download: https://siteURL/jira/secure/IssueNavigator.jspa?view=rss&&type=12&type=4&type=3&pid=10081&resolution=1&fixfor=10348&sorter/field=issuekey&sorter/order=DESC&sorter/field=priority&sorter/order=DESC&tempMax=100&reset=true&decorator=none
ログには以下のように表示されます。
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
診断
SSL Poke を使用して接続を検証する
Java クラス SSLPoke
を使用して、トラストストアに適切な証明書が含まれているかどうかを確認します。これによって、SSL サービスへの接続、入力バイトの送信、出力の監視が可能です。
- SSLPoke.class をダウンロードします。
Execute the class as per the below, changing the URL and port appropriately. Take care that you are running the same Java your application (Confluence, Jira, etc.) is running with. If you used the installer you will need to use
<application-home>/jre/java
$JAVA_HOME/bin/java SSLPoke jira.example.com 443
A mail server may be
mail.example.com 465
接続に失敗すると、以下のように出力されます。
$JAVA_HOME/bin/java SSLPoke jira.example.com 443
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:387)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
at sun.security.validator.Validator.validate(Validator.java:260)
at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1351)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:156)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:925)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:860)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1043)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1343)
at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:728)
at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123)
at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:138)
at SSLPoke.main(SSLPoke.java:31)
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:145)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:131)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382)
... 15 more
To get more details from a failed connection, use the
-Djavax.net.debug=ssl
parameter. For example:
java -Djavax.net.debug=ssl SSLPoke jira.example.com 443
接続に成功すると、以下のように表示されます。
$JAVA_HOME/bin/java SSLPoke jira.example.com 443
Successfully connected
If -Djavax.net.ssl.trustStore
is present in your JVM arguments, Java will use the truststore configured instead of the default (cacerts). You can verify whether the -Djavax.net.ssl.trustStore
parameter is causing problems by running the SSLPoke
test using the same JVM argument which will execute SSLPoke using your custom truststore. For example:
$JAVA_HOME/bin/java -Djavax.net.ssl.trustStore=/my/custom/truststore -Djavax.net.debug=ssl SSLPoke jira.example.com 443
If this fails (confirming that the truststore doesn't contain the appropriate certificates), the certificate will need to be imported into your defined custom truststore using the instructions in Connecting to SSL Services.
原因
Whenever Java attempts to connect to another application over SSL (e.g.: HTTPS, IMAPS, LDAPS), it will only be able to connect to applications it can trust. The way trust is handled in Java is that you have a truststore (typically $JAVA_HOME/lib/security/cacerts
). The truststore contains a list of all known Certificate Authority (CA) certificates, and Java will only trust certificates that are signed by one of those CAs or public certificates that exist within that truststore. For example, if we look at the certificate for Atlassian, we can see that the *.atlassian.com certificate has been signed by the intermediate certificates, DigiCert High Assurance EV Root CA and DigiCert High Assurance CA-3. These intermediate certificates have been signed by the root Entrust.net Secure Server CA :
These three certificates combined are referred to as the certificate chain, and, as they are all within the Java truststore (cacerts
), Java will trust any certificates signed by them (in this case, *.atlassian.com). Alternatively, if the *. atlassian.com certificate had been in the truststore, Java would also trust that site.
この問題は、自己署名 (CA が署名していない) 証明書、または Java トラストストアに存在しない証明書チェーンによって引き起こされます。Java はその証明書を信用せず、アプリケーションへの接続に失敗します。
For details on how to examine a website's certificate chain, see the section, View a certificate, in Secure Website Certificate.
ソリューション
- ターゲット インスタンスの公開証明書が、「SSL サービスへの接続」の手順に従って、トラストストアにインポートされていることを確認します。
- JRE/JDK が複数ある場合があるため、証明書が正しいトラストストアにインポートされていることを確認します。こちらについては、「Java のインストール」を参照してください。
- 適切なトラストストアが使用中であることを確認します。
-Djavax.net.ssl.trustStore
が設定されている場合、デフォルトのトラストストアの場所が上書きされるため、確認が必要です。 - このエラーが LDAP サーバーを LDAPS 経由で連携させるときに発生していて、複数の LDAP サーバーが存在する場合、LDAP ユーザー ディレクトリ構成の [Follow referrals] オプションの選択を解除します。詳細については「LDAP ディレクトリへの接続」をご確認ください。あるいは、他の LDAP サーバーの SSL 証明書を Confluence のトラストストアにインポートします。
- アンチウイルス ツールの「SSL スキャン」によって SSL/TLS がブロックされているかどうかを確認します。ブロックされていたら、この機能を無効化するか、ターゲット アドレスを除外するように設定します (方法については製品マニュアルをご確認ください)。
- Exchange などのメール サーバーに接続する場合、認証情報としてプレーン テキストが許可されていることを確認します。
- ターゲット サーバーが SSL を適切に提供するように構成されていることを確認します。これは SSL サーバー テスト ツールで行えます。
- これらすべてに失敗する場合、ご利用のトラストストアが古くなっている可能性がああります。ご利用のアプリケーションでサポートされている最新のバージョンに Jira をアップグレードしてください。
重要
Since the truststore only gets read once when the JVM is initialized, please restart the source application service after importing the new certificate(s).
SSL Poke の詳細
アトラシアンの SSL Poke のソース コードはこちらで確認できます。
SSL Poke のフォーク バージョンはコミュニティで提供されています。ここでは Java 11 やプロキシなどの追加の機能がサポートされます。
次のような良い例があります。