M2Crypto:覆盖主机名的连接后检查

发布于 2024-08-22 20:21:21 字数 228 浏览 11 评论 0原文

我正在使用 M2Crypto 0.20.2 和 python 2.4.3。我使用完全限定域名连接到服务器。服务器证书中的通用名称不使用 FQDN,因此我收到此错误:

M2Crypto.SSL.Checker.WrongHost: Peercertificate commonName does not match host

如何覆盖服务器的连接后检查主机名?

谢谢!

I am using M2Crypto 0.20.2 and python 2.4.3. I connect to the server with the fully qualified domain name. The common name in the server certificate does not use the FQDN so I get this error:

M2Crypto.SSL.Checker.WrongHost: Peer certificate commonName does not match host

How do I override the post connection check of the host name?

Thanks!

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

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

发布评论

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

评论(2

澉约 2024-08-29 20:21:21

设置 SSL.Connection.clientPostConnectionCheck = None 确实绕过了 WrongHost 检查,但它也绕过了许多您可能不想绕过的其他检查(例如检查是否有任何证书)。我建议使用 try/ except 组合来捕获 WrongHost,因为在连接函数结束之前实际上没有检查或执行任何其他操作。

换句话说,仅通过捕获此异常就不会留下任何未完成的内容(据我在源代码中看到),因此我说这是比使用

SSL.Connection.clientPostConnectionCheck = None 更好的路线。 >

这消除了许多其他有价值的支票。

至于进行 xmlrpc 调用时的错误,在不知道错误是什么的情况下,我无法确定。我猜测这是 ProtocolError 异常,如果是这种情况,您只需编辑 m2xmlrpclib.py 就不会使用您收到的 ProtocolError 异常中列出的 errcode 引发异常。

Setting SSL.Connection.clientPostConnectionCheck = None does bypass the WrongHost check, but it also bypasses many other checks that you probably don't want to bypass (such as checking if there is any certificate at all). I would recommend using a try/except combo to catch the WrongHost because there isn't really anything else that is checked or performed before the end of the connect function.

In other words, nothing is left undone (as far as I can see in the source) by just catching this exception, and therefore I say that it is a better route than using

SSL.Connection.clientPostConnectionCheck = None

which gets rid of a lot of other valuable checks.

As far as the error when making the xmlrpc call, I can't say for sure without knowing what the error is. I'm guessing that it is the ProtocolError exception and if that is the case you can just edit m2xmlrpclib.py to not raise an exception with the errcode that is listed in the ProtocolError exception you are getting.

来世叙缘 2024-08-29 20:21:21

从那时起,属性名称已更改为:

M2Crypto.SSL.Connection.postConnectionCheck = None

Since that time, the attribute name has changed to:

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