私はクライアント側でSpring RESTTemplateを使用してRESTエンドポイントを呼び出しています。この場合のクライアントはSpringアプリケーションであり、Tomcatはサーブレットコンテナです。SSLハンドシェイクのトラストストアが見つからないのはなぜですか?
HTTPSエンドポイントへの接続に関する問題が発生しています。トラストストアへの有効なパスが見つからないことを示すエラーが表示されます。これはどこで指定できますか?これはコンテナレベルかアプリケーションの設定(春)レベルで行われますか?
スタックトレース:
org.springframework.web.client.ResourceAccessException: I/O error:
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException:
unable to find valid certification path to requested target;
nested exception is 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
org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:330)
org.springframework.web.client.RestTemplate.execute(RestTemplate.java:292)
org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:227)
そのコードを記述するの? – kamaci
SSLContextクラス自体で静的呼び出しを行っているので、好きな場所に書き込むことができます。あなたが同じクラスローダーコンテキストで、最初のHttpClientコールの前に呼び出すのであれば、あなたはうまくいくはずです。 –
確かに:上記のようにSSLContextのTrustManagerを変更するのは永続的なアクションではありません。したがって、アプリケーションを起動するたびに実行する必要があります。 – ptikobj