我有一个SAML断言,我希望在.Net中使用WSSecurityTokenSerializer.
尽管存在一些问题,我还是拥有了密钥链和SAML XML .
首先,我从HTTPS POST获得SAML断言:
// spec says "SAMLResponse="
string rawSamlData = Request["SAMLResponse"];
// read the base64 encoded bytes
byte[] samlData = Convert.FromBase64String(rawSamlData);
// read back into a UTF string
string samlAssertion = Encoding.UTF8.GetString(samlData);
// get the SAML data in an XML reader
var assertionPostStream = new StringReader(samlAssertion);
var reader = XmlReader.Create(assertionPostStream);
Run Code Online (Sandbox Code Playgroud)
然后我得到了我的IdP提供的密钥:
// get the key data
byte[] certificateData = System.IO.File.ReadAllBytes("myKeys.p7b");
// decode the keys
var cms = new SignedCms(SubjectIdentifierType.IssuerAndSerialNumber);
cms.Decode(certificateData);
// we have …Run Code Online (Sandbox Code Playgroud)