There is another question. I got plain text saml assertion on RP side, I guess I have to Encrypt the SAML assertion for the RSTR in my RP-STS side in order to get encrypted saml in RP. I guess your XmlEncryptedTokenSerializer.cs and
EncryptedData.cs can do the encryption, but when I tried, I got this.cipherText = null in the WriteTo method call.
public void WriteTo(XmlWriter writer)
writer.WriteStartElement("enc", "CipherData", "http://www.w3.org/2001/04/xmlenc#");
writer.WriteStartElement("enc", "CipherValue", "http://www.w3.org/2001/04/xmlenc#");
if (this.iv != null)
writer.WriteBase64(this.iv, 0, this.iv.Length);
writer.WriteBase64(this.cipherText, 0, this.cipherText.Length); //this.cipherText = null here
I added some logging in SetCipherValueFragments method of EncryptedData.cs file:
public void SetCipherValueFragments(byte initialisationVector, byte cipher)
this.iv = initialisationVector;
this.cipherText = cipher;
System.Text.Encoding enc = System.Text.Encoding.ASCII;
string cipherTextString = "cipher = " + enc.GetString(cipher);
string cipherTextString2 = "this.cipherText = " + enc.GetString(this.cipherText);
Both cipher and this.cipherText are not null. I don't understand why this.cipherText become null in WriteTo method, since SetCipherValueFragments( ) is called before WriteTo( ).