相关疑难解决方法(0)

如何在.NET中验证RSA-SHA512 XML签名?

MSDN站点的帮助下,我可以轻松验证XML DSig是否正确.如果使用签名方法sha1,它可以完美地工作.

但是,当我收到SignatureMethod RSA-SHA512(http://www.w3.org/2001/04/xmldsig-more#rsa-sha512)时,CheckSignature()会因CryptograhicException而中断:无法为签名创建SignatureDescription算法提供.

似乎CheckSignature()无法验证RSA-SHA512签名.

有谁知道如何检查这些签名?

从MSDN站点获取的代码是:

public static bool VerifyXml(XmlDocument doc, bool removeSignatureElement = false)
{
    // Check arguments.
    if (doc == null)
        throw new ArgumentException("doc");

    // Create a new SignedXml object and pass it the XML document class.
    SignedXml signedXml = new SignedXml(doc);

    // Find the "Signature" node and create a new XmlNodeList object.
    XmlNodeList nodeList = doc.GetElementsByTagName("Signature", Constants.NamespaceDSig);

    // Throw an exception if no signature was found.
    if (nodeList.Count …
Run Code Online (Sandbox Code Playgroud)

c# sha1 rsa sha512 xml-signature

6
推荐指数
2
解决办法
5784
查看次数

C#支持对单个XML元素进行RSA SHA 256签名

我遇到过使用.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)

c# xml signature sha256 x509

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×2

rsa ×1

sha1 ×1

sha256 ×1

sha512 ×1

signature ×1

x509 ×1

xml ×1

xml-signature ×1