2016-07-29 62 views
0

我正在尝试使用SSOCircle和默认密钥存储库的Spring SAML示例项目。 将SP元数据导入SSOCircle后,SSO正常工作。Spring SAML示例:不支持SSOCircle SHA256

现在,我想将加密算法从SHA-1更改为RSA SHA-256。 所以我延长SAMLBootstrap类如下所示:

public final class CustomSAMLBootstrap extends SAMLBootstrap { 

    @Override 
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { 
     super.postProcessBeanFactory(beanFactory); 
     BasicSecurityConfiguration config = (BasicSecurityConfiguration) Configuration.getGlobalSecurityConfiguration(); 
     config.registerSignatureAlgorithmURI("RSA", SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256); 
     config.setSignatureReferenceDigestMethod(SignatureConstants.ALGO_ID_DIGEST_SHA256); 
    } 

同样在这里是扩展的元数据配置

<!-- Extended metadata properties --> 
<bean id="extendedMetadataSP" class="org.springframework.security.saml.metadata.ExtendedMetadata"> 
    <property name="local" value="true"/> 
    <property name="securityProfile" value="metaiop"/> 
    <property name="sslSecurityProfile" value="pkix"/> 
    <property name="signingKey" value="apollo"/> 
    <property name="encryptionKey" value="apollo"/> 
    <property name="signMetadata" value="true" /> 
    <property name="signingAlgorithm" value="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" /> 
    <property name="idpDiscoveryEnabled" value="true"/> 
    <property name="idpDiscoveryURL" value="${entityBaseURL}/saml/discovery"/> 
    <property name="idpDiscoveryResponseURL" value="${entityBaseURL}/saml/login?disco=true"/> 

</bean> 

所以我经由org.springframework.security.saml.metadata.MetadataGenerator豆再生的元数据,并试图重新上传新生成的SP xml。尽管SSOCircle将以007错误代码失败。

enter image description here

在这一点上我不知道,如果有一个额外步骤才能使用SHA256上SSOCircle完成我吗?

有人可以帮忙吗?

编辑:

我上传的元数据来SSOCircle时遇到的问题,我相信这与其中签名algorith指定为SHA256,如下EntityDescriptor部分做:

<?xml version="1.0"?> 
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> 
<ds:SignedInfo> 
    <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> 
    <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/> 
    <ds:Reference URI="#urn_com_apakgroup_bristol"> 
     <ds:Transforms> 
      <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/> 
      <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> 
     </ds:Transforms> 
     <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/> 
     <ds:DigestValue>mAT5iN6IWyTCQiPplFmOq4vu8SUzCBfpAC4XBOu2+eM=</ds:DigestValue> 
    </ds:Reference> 
</ds:SignedInfo> 
<ds:SignatureValue>i6hH............bA==</ds:SignatureValue> 
<ds:KeyInfo> 
    <ds:X509Data> 
     <ds:X509Certificate>MIIDZTCCA............eVdvh</ds:X509Certificate> 
    </ds:X509Data> 
</ds:KeyInfo> 
</ds:Signature> 

将signMetadata更改为false,但不幸的是它没有任何区别。

<property name="signMetadata" value="false" /> 

SAML RESPONSE:

2016-09-13 15:03:06,786 DEBUG org.opensaml.xml.security.SigningUtil:115 - Computing signature over input using private key of type RSA and JCA algorithm ID SHA256withRSA 
2016-09-13 15:03:06,802 DEBUG org.opensaml.xml.security.SigningUtil:123 - Computed signature: 8b4...dfa9 
2016-09-13 15:03:06,802 DEBUG opensaml.saml2.binding.encoding.HTTPRedirectDeflateEncoder:251 - Generated digital signature value (base64-encoded) i0...== 
2016-09-13 15:03:06,803 DEBUG PROTOCOL_MESSAGE:74 - 
<?xml version="1.0" encoding="UTF-8"?><saml2p:AuthnRequest xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" AssertionConsumerServiceURL="http://localhost:8080/saml/SSO" Destination="https://idp.ssocircle.com:443/sso/SSORedirect/metaAlias/publicidp" ForceAuthn="false" ID="ac8eeg2j9d932hh4fe90fa71844e00" IsPassive="false" IssueInstant="2016-09-13T14:03:06.775Z" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Version="2.0"> 
    <saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">...[my-sp]...</saml2:Issuer> 
</saml2p:AuthnRequest> 

2016-09-13 15:03:06,803 DEBUG opensaml.ws.message.encoder.BaseMessageEncoder:56 - Successfully encoded message. 
2016-09-13 15:03:06,804 DEBUG springframework.security.saml.storage.HttpSessionStorage:93 - Storing message ac8eeg2j9d932hh4fe90fa71844e00 to session C17D8A94DED2F79BDD92CBF7A99462C6 
2016-09-13 15:03:06,805 INFO springframework.security.saml.log.SAMLDefaultLogger:127 - AuthNRequest;SUCCESS;0:0:0:0:0:0:0:1;...[my-sp]...;https://idp.ssocircle.com;;; 
+0

您能否提供一个导致错误的示例请求以及上面提到的调试跟踪? – Hos

+0

我用SHA256创建了keystore,它工作。其他地方你可能有问题。 – Alic

回答

0

其原因error7是所述元数据的签名不能被验证。这在“how-to section”中有描述:“签名的元数据可能会导致验证问题。我们建议删除签名作为最快的解决方法。”

你必须启用元数据签名:

<property name="signMetadata" value="true" /> 

再将其为 “假”。

+0

嗨,我确实把它变成假,没有任何区别。感谢您的帮助 – nuvio

+0

如果您不介意,请在此处发布元数据。 – Hos