1

受信した認証応答 SAML メッセージの復号化に問題があります。私のアプリは、異なるタイプの 2 つの IdP に接続されています。Frist は ForgeRocks、OpenAM、および 2 番目の Microsoft の ADFS サーバーです。両方の IdP には、暗号化と署名のための同じ証明書公開鍵を含む同じサービス プロバイダー メタデータ ドキュメントが提供されました。

Case 01 IdP : OpenAM, ForgeRock 結果 : 正しく復号・応答する。

ケース 02 IdP : ADFS 2.0、Microsoft 結果 : 復号化に失敗しました。エラー: CryptographicException、Bad Data。

同じ非対称キー ペアに対して IdP 側の暗号化が異なる可能性はありますか? それとも私は何か間違っていますか?

ご覧のとおり、EncryptedAssertion xml ノードに違いがあります。EncryptionMethod アルゴリズムが異なります。

ここに重要なノードがあります。

OpenAM、フォージロック

<saml:EncryptedAssertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
<xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
                    Type="http://www.w3.org/2001/04/xmlenc#Element"
                        >
  <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"
                         xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
                               />
  <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
    <xenc:EncryptedKey xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
      <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"
                             xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
                                       />
      <xenc:CipherData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
        <xenc:CipherValue xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
        </xenc:CipherValue>
      </xenc:CipherData>
    </xenc:EncryptedKey>
  </ds:KeyInfo>
  <xenc:CipherData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
    <xenc:CipherValue xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
    </xenc:CipherValue>
  </xenc:CipherData>
</xenc:EncryptedData>

ADFS 2.0、マイクロソフト

<EncryptedAssertion xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
<xenc:EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
                    xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
                        >
  <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" />
  <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
    <e:EncryptedKey xmlns:e="http://www.w3.org/2001/04/xmlenc#">
      <e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p">
        <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
      </e:EncryptionMethod>
      <KeyInfo>
        <ds:X509Data xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
          <ds:X509IssuerSerial>
            <ds:X509IssuerName>CN=certName</ds:X509IssuerName>
            <ds:X509SerialNumber>-18xxxxxx</ds:X509SerialNumber>
          </ds:X509IssuerSerial>
        </ds:X509Data>
      </KeyInfo>
      <e:CipherData>
        <e:CipherValue></e:CipherValue>
      </e:CipherData>
    </e:EncryptedKey>
  </KeyInfo>
  <xenc:CipherData>
    <xenc:CipherValue></xenc:CipherValue>
  </xenc:CipherData>
</xenc:EncryptedData>

ご覧のとおり、使用される暗号化方法には違いがあります。また、2 番目のケースでは、証明書のエイリアス名とシリアル番号があります。また、シリアル番号は負の値です (自己署名証明書を使用している可能性があります)。

ありがとう、

4

1 に答える 1

0

対応する xml ノードには復号化するデータがないため、この例外があります。これが理由です。

<e:CipherData>
<e:CipherValue>No data!!!</e:CipherValue>
</e:CipherData>
</e:EncryptedKey>
</KeyInfo>
<xenc:CipherData>
<xenc:CipherValue>No data!!!</xenc:CipherValue>
</xenc:CipherData>

例:

<EncryptedAssertion xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
		<xenc:EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
				    xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
				    >
		    <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" />
		    <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
			<e:EncryptedKey xmlns:e="http://www.w3.org/2001/04/xmlenc#">
			    <e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p">
				<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
			    </e:EncryptionMethod>
			    <KeyInfo>
				<ds:X509Data xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
				    <ds:X509IssuerSerial>
					<ds:X509IssuerName>CN=name, O=Name, S=CA, C=us</ds:X509IssuerName>
					<ds:X509SerialNumber>0</ds:X509SerialNumber>
				    </ds:X509IssuerSerial>
				</ds:X509Data>
			    </KeyInfo>
			    <e:CipherData>
				<e:CipherValue>qSMgmgpO0+1vhdt5wvyhNT+uh3BhmOlFD4IiWTPoj2N90nOUzwEoEkWCuGzHDizxq6rvc5eoikjgcbz5TYFlIX+eizyxcJQFl02t...  SOME VALUES HERE=</e:CipherValue>
			    </e:CipherData>
			</e:EncryptedKey>
		    </KeyInfo>
		    <xenc:CipherData>
			<xenc:CipherValue>RSCxYAMJ7RaD+MtEcnmE9EwLmvDJgTsXx5MOKJYUJiAmQWziSLNolZQYt5xgUPHJaD+co/PoWwifWuobHdClFwBBMR/lAqWAHIQldP+ro ...  SOME VALUES HERE=</xenc:CipherValue>
		    </xenc:CipherData>
		</xenc:EncryptedData>
	    </EncryptedAssertion>
	

于 2016-07-17T23:27:29.487 に答える