httpsプロトコルを使用して、Web からいくつかのメタデータをインポートしたいと思います。
@Bean
public HTTPMetadataProvider ssoCircleMetadataProvider()
throws MetadataProviderException {
String metadataURL = "https://idp.ssocircle.com/idp-meta.xml";
final Timer backgroundTaskTimer = new Timer(true);
HTTPMetadataProvider provider = new HTTPMetadataProvider(
backgroundTaskTimer, httpClient(), metadataURL);
provider.setParserPool(parserPool());
return provider;
}
ドキュメントを読むと、次のステップが見つかりました。
デフォルトでは、HTTPS 経由で HTTP ベースのプロバイダーを使用してメタデータをロードすると、JDK で構成された信頼検証が実行されます。keyStore で証明書を使用する場合は、HTTP クライアントが使用する socketFactory を変更する次の Bean を追加します。
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass" value="org.apache.commons.httpclient.protocol.Protocol"/>
<property name="targetMethod" value="registerProtocol"/>
<property name="arguments">
<list>
<value>https</value>
<bean class="org.apache.commons.httpclient.protocol.Protocol">
<constructor-arg value="https"/>
<constructor-arg>
<bean class="org.springframework.security.saml.trust.httpclient.TLSProtocolSocketFactory"/>
</constructor-arg>
<constructor-arg value="443"/>
</bean>
</list>
</property>
</bean>
Java Config で変換すると、次のようになります。
@Bean
public Protocol httpClientProtocol() {
org.springframework.security.saml.trust.httpclient.TLSProtocolSocketFactory factory =
new org.springframework.security.saml.trust.httpclient.TLSProtocolSocketFactory();
Protocol httpClientProtocol = new Protocol ("https", factory, 443);
return httpClientProtocol;
}
@Bean
public MethodInvokingFactoryBean methodInvokingFactoryBean() {
MethodInvokingFactoryBean methodInvokingFactoryBean = new MethodInvokingFactoryBean();
methodInvokingFactoryBean.setTargetClass(Protocol.class);
methodInvokingFactoryBean.setTargetMethod("registerProtocol");
Object[] args = {"https", httpClientProtocol()};
methodInvokingFactoryBean.setArguments(args);
return methodInvokingFactoryBean;
}
しかし、org.springframework.security.saml.trust.httpclient.TLSProtocolSocketFactory
クラスの結果は見つかりませんでした。Spring SAMLのバージョン1.0.0-RC2
を使用しています。
私は何か間違ったことをしていますか?
このエラーを修正し、必要に応じてメタデータをロードするにはどうすればよいですか?
アップデート
SNAPSHOT リポジトリを使用することで、TLSProtocolSocketFactory クラスを使用できます。SSOCircle の証明書をキーストアにインポートしましたが、それにもかかわらず、アプリケーションは次のようなエラーを返します。
[2014-07-31 17:33:27.596] boot - 11800 ERROR [localhost-startStop-1] --- HTTPMetadataProvider: Error retrieving metadata from https://idp.ssocircle.com/idp-meta.xml
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
更新 2
あなたの提案に従ってコードを修正しました。すべての証明書をキーストアにインポートしましたが、起動時にアプリケーションが次のエラーを返します。
[2014-08-01 10:02:38.961] boot - 14704 DEBUG [localhost-startStop-1] --- BasicX509CredentialNameEvaluator: Supplied trusted names are null or empty, skipping name evaluation
[2014-08-01 10:02:38.962] boot - 14704 DEBUG [localhost-startStop-1] --- MetadataCredentialResolver: Attempting PKIX path validation on untrusted credential: [subjectName='CN=ADFS Signing - ststest-vdenotarisnet.vdenotaris.it']
[2014-08-01 10:02:39.028] boot - 14704 ERROR [localhost-startStop-1] --- MetadataCredentialResolver: PKIX path construction failed for untrusted credential: [subjectName='CN=ADFS Signing - ststest-vdenotarisnet.vdenotaris.it']: unable to find valid certification path to requested target
[2014-08-01 10:02:39.028] boot - 14704 DEBUG [localhost-startStop-1] --- PKIXSignatureTrustEngine: Signature trust could not be established via PKIX validation of signing credential
[2014-08-01 10:02:39.028] boot - 14704 DEBUG [localhost-startStop-1] --- BaseSignatureTrustEngine: Failed to establish trust of KeyInfo-derived credential
[2014-08-01 10:02:39.028] boot - 14704 DEBUG [localhost-startStop-1] --- BaseSignatureTrustEngine: Failed to verify signature and/or establish trust using any KeyInfo-derived credentials
[2014-08-01 10:02:39.029] boot - 14704 DEBUG [localhost-startStop-1] --- PKIXSignatureTrustEngine: PKIX validation of signature failed, unable to resolve valid and trusted signing key
[2014-08-01 10:02:39.029] boot - 14704 ERROR [localhost-startStop-1] --- SignatureValidationFilter: Signature trust establishment failed for metadata entry http://ststest.vdenotaris.local/adfs/services/trust
[2014-08-01 10:02:39.031] boot - 14704 ERROR [localhost-startStop-1] --- AbstractReloadingMetadataProvider: Error filtering metadata from https://ststest.vdenotaris.local/FederationMetadata/2007-06/FederationMetadata.xml
org.opensaml.saml2.metadata.provider.FilterException: Signature trust establishment failed for metadata entry
使用される証明書は GoDaddy によって検証されることに注意してください。