相关疑难解决方法(0)

使用WSSecurityTokenSerializer读取在.Net中验证SAML断言的问题

我有一个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)

.net x509certificate single-sign-on saml-2.0 pkcs#7

3
推荐指数
1
解决办法
6403
查看次数

标签 统计

.net ×1

pkcs#7 ×1

saml-2.0 ×1

single-sign-on ×1

x509certificate ×1