我正在嘗試使用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錯誤代碼失敗。
在這一點上我不知道,如果有一個額外步驟才能使用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;;;
您能否提供一個導致錯誤的示例請求以及上面提到的調試跟蹤? – Hos
我用SHA256創建了keystore,它工作。其他地方你可能有問題。 – Alic