问题描述
我有需要使用的SOAP服务,该服务需要证书和SAML 1.1
I have a SOAP service that I need to consume that requires a Certificate and SAML 1.1
到目前为止,我已经能够从商店中获得X509Certificate2,并且我执行了一个client.ClientCertificates.Add(X509Certificate2).
So far I am able to get the X509Certificate2 from the store, and I do a client.ClientCertificates.Add(X509Certificate2).
接下来,我需要知道如何添加SAML令牌.我正在尝试做一个client.RequestSoapContext.Security.Tokens.Add(),但不知道如何添加SAML令牌.
Next I need to know how to add a SAML token. I am attempting to do a client.RequestSoapContext.Security.Tokens.Add() but do Not know how to add in the SAML token.
在此方面的任何帮助将不胜感激.
Any help on this would be greatly appreciated.
谢谢.
推荐答案
X509Certificate2 cert = new X509Certificate2(<initialization parameters>); //The cert details here
X509SecurityToken signatureToken = new X509SecurityToken(cert);
SoapContext requestContext = service.RequestSoapContext;
requestContext.Security.Tokens.Add(signatureToken);
MessageSignature signature = new MessageSignature(signatureToken);
requestContext.Security.Elements.Add(signature);
有关更多信息,请单击此处,以参考有关如何:向SOAP消息添加安全凭证的信息.
for more information, Click here to refer about How to: Add Security Credentials to a SOAP Message.
这篇关于使用带有证书和SAML 1.1的SOAP服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!