English 中文(简体)
• 如何核实Xml号签名的机器储存证书
原标题:How to verify certificate in SignedXml against machine store

我愿对机器储存证书的“上签字进行核实。 该代码用于核实签名:

internal bool VerifySignature(XmlDocument xml)
{
    var signedXml = new SignedXml(xml);
    var nsMgr = new XmlNamespaceManager(xml.NameTable);
    nsMgr.AddNamespace("ds", "http://www.w3.org/2000/09/xmldsig#");
    signedXml.LoadXml((XmlElement)xml.SelectSingleNode("//ds:Signature", nsMgr));
    return signedXml.CheckSignature();
}

签字对罚款进行核实,但仅对自己进行核查,而不是对机器上安装的证书进行核查。 是否有办法对照当地证书库中的基本证书检查?

最佳回答

If anyone is interested, I used the CheckSignature(X509Certificate2, Boolean) method. I got the certificate from the Signature object and checked it like this:

var x509data = signedXml.Signature.KeyInfo.OfType<KeyInfoX509Data>().First();
var verified = false;
if(x509data != null)
{
    var cert = x509data.Certificates[0] as X509Certificate2;
    verified = cert != null && signedXml.CheckSignature(cert, false);
}
return verified;
问题回答

You can use the overload of the CheckSignature method which takes an AsymmetricAlgorithm.

页: 1 你们可以通过X509S 商店这样做。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签