我遇到过使用.NET Framework 4.5版的阻止程序来处理带有数字签名的XML.
我的问题是基于使用RSA SHA-256算法使用X.509证书签署单个XML元素的需要.我已经阅读了很多关于这个主题的.NET帖子,看来最初在CLR安全项目RSAPKCS1SHA256SignatureDescription.cs类中开发了一个解决方案.RSAPKCS1SHA256SignatureDescription当然已经被整合到.net运行时中,从.NET 4.5开始,现在可以在分布式二进制System.Deployment.dll下使用.我在.NET中尝试使用RSA SHA-256对特定的XML元素进行签名,但是还没有取得任何成功.
我正在尝试使用WSSE令牌签署符合Oasis ebms标准的SOAP消息.请注意,该课程的目的是为了满足Soap With Attachments(SwA)和签署个人附件.我的代码如下
我的代码如下:
using System;
using System.Collections.Generic;
using System.IO;
using System.IdentityModel.Tokens;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.Xml;
using System.ServiceModel.Channels;
using System.ServiceModel.Security;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Serialization;
using System.Deployment.Internal.CodeSigning;
namespace TestCSharpX509CertificateRSSHA256
{
public class SignatureSupportUtility
{
private bool IsSignatureContentTransform
{
get
{
return true;
//get IsSignatureContentTransform
}
}
public SignatureSupportUtility()
{
Register();
}
private static void Register()
{
CryptoConfig.AddAlgorithm(typeof(RSAPKCS1SHA256SignatureDescription), "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
}
private void Sign(Message message, string[] elementIdsToSign, …Run Code Online (Sandbox Code Playgroud)