如何在本机 C++ 中验证 XML 数字签名没有 MSXML 5?

发布于 2024-09-18 09:58:35 字数 205 浏览 5 评论 0原文

我正在考虑使用 XML dsig 进行基本应用程序许可。该应用程序是本机 Windows 代码(无 .net)。我可以轻松地使用 .net 离线创建 dsig,但随后我想在本机 C++ 中验证它。据我目前所知,MSXML V5 可以完成这项工作,但不能使用,而且 V6 删除了对 dsigs 的支持。

那么如何轻松验证由本机 C++ 中的 .net 代码生成的 XML dsig?

I'm considering using an XML dsig for basic app licensing. The app is native windows code (no .net). I can easily use .net to create a dsig offline, but then I want to verify it in native c++. From what I've found so far MSXML V5 will do the job, but musn't be used and V6 removes support for dsigs.

So how can I easily verify an XML dsig produced by .net code in native C++?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

手长情犹 2024-09-25 09:58:35

不幸的是,XML 签名仅随 MSXML 5.0 一起提供。问题是 XML-DSig 实际上并不被视为 MSXML 的一个功能。最好将 MSXML 5.0 视为一个分支(MSXML 奇怪的同父异母的兄弟),而不是该系列的一部分。他们最好将其命名为 MSXML 之外的其他名称,因为它会造成混乱。几乎没有任何文档,并且 无法分发它。甚至 Microsoft 的 XML 团队也表示“不要使用它"。

但这一切对你没有帮助。真正的问题是 XML 数字签名很棘手。 MSXML 5.0 之所以实现它,是因为 MS Office 完全控制了 XML;正因为如此,可以获得一致的结果。无法保证从 .NET 生成的 XML 签名可与 MSXML 5.0 互操作。您甚至可能会得到不一致的结果,有时有效,有时无效。

您需要做的是编写托管 C++ 代码,在其中可以使用最初生成签名的相同 .NET 功能。它不是原生 C++,但它会给您带来一致的结果。唯一的选择是找到一个可以在 .NET 和 C++ 中使用的库来生成数字签名。

Unfortunately, XML Signatures comes with MSXML 5.0 only. The thing is that XML-DSig isn't actually considered a feature of MSXML. It's best to consider MSXML 5.0 an offshoot - the strange step brother of MSXML - instead of part of the line. They would have been better off naming it something besides MSXML for all the confusion it has caused. There's barely any documentation for it and no way to distribute it. Even the XML Team at Microsoft says "Don't use it".

But all that doesn't help you. The real problem is that XML Digital Signatures are tricky things. MSXML 5.0 only implemented it because MS Office had total control over the XML; and because of that, could get consistent results. There's no guarantee that an XML signature generated from .NET is interoperable with MSXML 5.0. You might even have inconsistent results, where it works sometimes and doesn't work other times.

What you'll need to do is to write managed C++ code where you can use the same .NET features that generated the signature in the first place. It's not native C++, but it will get you consistent results. The only other alternative is to find a library that you can use in both .NET and C++ that can generate a digital signature.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文