如何使用 m2crypto 在非 SSL 设置中验证 X509 证书链

发布于 2024-08-28 19:23:26 字数 263 浏览 6 评论 0原文

我试图弄清楚如何使用 m2crypto 验证从 X509 证书的公钥版本到一组已知根 CA 的信任链(当信任链可能任意长时)。 SSL.Context 模块看起来很有希望,只是我不是在 SSL 连接的上下文中执行此操作,而且我看不到传递给 load_verify_locations 的信息是如何使用的。

本质上,我正在寻找相当于以下的界面: openssl verify pub_key_x509_cert

m2crypto 中有类似的东西吗?

谢谢。

I'm trying to figure out how to, using m2crypto, validate the chain of trust from a public key version of a X509 certificate back to one of a set of known root CA's when the chain may be arbitrarily long. The SSL.Context module looks promising except that I'm not doing this in the context of a SSL connection and I can't see how the information passed to load_verify_locations is used.

Essentially, I'm looking for the interface that's equivalent to:
openssl verify pub_key_x509_cert

Is there something like that in m2crypto?

Thanks.

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

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

发布评论

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

评论(2

初心 2024-09-04 19:23:26

我修改了一个不同的 M2Crypto 补丁,这样我们就能够根据 CA 链验证 X509 证书,并且它允许使用证书吊销列表 (CRL)。

允许使用 M2Crypto 进行链验证的核心是在 X509_Store_Context 上公开“verify_cert()”。
基本流程是:

  1. 将您的 CA/CRL 添加到 X509_Store
  2. 使用 X509_Store_Context 验证感兴趣的证书

我的补丁增强了 CRL 支持并允许链验证。
https://bugzilla.osafoundation.org/show_bug.cgi?id=12954#c2

我们将此补丁用作 Pulp 的一部分,下面有一个 wiki 页面,其中分享了有关我们如何使用链进行验证的更多信息:
https://fedorahosted.org/pulp/wiki/CertChainVerification

I have modified a different M2Crypto patch and with this we are able to verify a X509 Certificate against a chain of CAs, plus it allows the usage of Certificate Revocation List (CRL)s.

The heart of allowing chain verification with M2Crypto is exposing "verify_cert()" on a X509_Store_Context.
Basic flow is:

  1. Add your CAs/CRLs to a X509_Store
  2. Use a X509_Store_Context to verify the certificate of interest

My patch enhances CRL support as well as allowing chain verification.
https://bugzilla.osafoundation.org/show_bug.cgi?id=12954#c2

We are using this patch as part of Pulp, we have a wiki page below which shares some more info on how we are doing the verification with a chain:
https://fedorahosted.org/pulp/wiki/CertChainVerification

惟欲睡 2024-09-04 19:23:26

有一个补丁可能需要稍微更新,并且需要单元测试供我检查。欢迎贡献!

另一种复杂的方法是创建一个内存中的 SSL 会话,您可以在其中进行验证。 Twisted 包装器有效地以这种方式工作; Twisted 充当哑网络管道,不了解任何数据,M2Crypto 加密/解密内存中的数据,同时进行证书验证。

There is a patch that might need to be updated slightly, and it would need unit tests for me to check it in. Contributions welcome!

Another convoluted way would be to create an in-memory SSL session where you do the validation. The Twisted wrapper effectively works this way; Twisted acts as dumb network pipe without knowing anything about the data, and M2Crypto encrypts/decrypts the data in memory, doing certificate validation on the side.

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