#1个质量TLS证书,等待识别测试仪
trustme的Python项目详细描述
你写了一个很酷的网络客户端或服务器。它加密连接 使用TLS。你的测试 套件需要与自身建立TLS连接。
哦哦。您的测试套件可能没有有效的tls 证书现在怎么办?
trustme是一个很小的python包,它只做一件事:它给您 一个fake 可用于生成假tls证书的证书颁发机构(ca) 在你的测试中使用。好吧,严格地说,它们是真正的肯定,它们是 刚刚由你的CA签署,没人相信。但你可以相信 它。相信我。
生命统计
安装:pip install -U trustme
文档:https://trustme.readthedocs.io
bug tracker和源代码:https://github.com/python-trio/trustme
测试时间:python 2.7和python 3.5+,cpython和pypypy
许可证:MIT或Apache2,由您选择。
行为准则:请投稿人遵守我们的code of conduct 在所有项目空间中。
备忘单
importtrustme# ----- Creating certs -----# Look, you just created your own certificate authority!ca=trustme.CA()# And now you issued a cert signed by this fake CA# https://en.wikipedia.org/wiki/Example.orgserver_cert=ca.issue_cert(u"test-host.example.org")# That's it!# ----- Using your shiny new certs -----# You can configure SSL context objects to trust this CA:ca.configure_trust(ssl_context)# Or configure them to present the server certificateserver_cert.configure_cert(ssl_context)# You can use standard library or PyOpenSSL context objects here,# trustme is happy either way.# ----- or -----# Save the PEM-encoded data to a file to use in non-Python test# suites:ca.cert_pem.write_to_path("ca.pem")server_cert.private_key_and_cert_chain_pem.write_to_path("server.pem")# ----- or -----# Put the PEM-encoded data in a temporary file, for libraries that# insist on that:withca.cert_pem.tempfile()asca_temp_path:requests.get("https://...",verify=ca_temp_path)
常见问题解答
我应该把这些证书用于任何真实的东西吗?当然不是。
为什么不使用自签名证书?更多 现实的。您不必禁用证书验证代码 在您的测试套件中,这很好,因为您想测试 在生产环境中运行,您将never禁用证书 生产中的验证码,对吧?而且他们也很容易 与合作。实际上在很多情况下更容易。
如果我想测试我的代码如何处理一些非常奇怪的tl 配置?当然,我很高兴扩展api以提供更多 控制生成的证书,至少只要它 不会变成二流再出口 cryptography。(如果你真的需要 完全通用的x.509库,那么他们做得很好。)Let’s talk,或者发送 公关部