gpt4 book ai didi

python - 相互 SSL 身份验证 - 客户端和服务器端。 Python -> Django/Twisted/ Tornado

转载 作者:行者123 更新时间:2023-11-28 18:52:41 24 4
gpt4 key购买 nike

我正在构建一个 python 应用程序,其中客户端将从服务器(也运行 python)请求 xml 页面。

我想在puppet配置管理系统上做点什么。 Puppet 的工作原理如下:

1) If the client runs for the 1st time, it generates a Certificate Signing Request and a private key. The former is an x509 certificate that is self-signed.
2) The client connects to the master (at this time the client is not authenticated) and sends its CSR, it will also receives the CA certificate and the CRL in return.
3) The master stores locally the CSR
4) The administrator checks the CSR and can eventually sign it (this process can be automated with autosigning). I strongly suggest verifying certificate fingerprint at this stage.
5) The client is then waiting for his signed certificate, which the master ultimately sends.
6) All next communications will use this client certificate. Both the master and client will authenticate each others by virtue of sharing the same CA.
(from http://www.masterzen.fr/2010/11/14/puppet-ssl-explained/)

我不会做的主要是:
- 哪些库最好用?
- 在服务器端使用什么? apache/nginx 背后的 Django 是否能够在第一次运行时签署证书并在之后使用证书进行身份验证,或者我需要在前端使用类似 twisted 的东西?
- 发送 CSR 的最佳方式是向服务器发送 POST?
- 有人知道是否有一些代码示例可以同时涵盖客户端和服务器端吗?
- 是否有任何其他方法无需人工迭代即可在客户端/服务器之间建立可信连接(Web 服务之间身份验证的最佳实践是什么)?

最佳答案

有一个围绕 M2Crypto 的 Python 包装器,名为 pki这使得创建 CSR 等变得如此容易。您应该能够为此使用 Django,我认为您没有理由需要 Twisted。

您也可以通过 POST 发送 CSR,是的,其中没有任何 secret 信息 - 这就是重点。

我链接到的 pki 包有相当详尽的文档字符串,应该可以让你继续。

我认为如果没有任何人为干预,您将无法建立“可信连接”。信任是人类的概念 - 因此您至少需要批准第一个连接请求,并希望您能验证尝试连接的人是否真正获得授权。

请注意,在此上下文中的“验证”意味着调用某人并询问他们是谁以及他们为什么要尝试连接到您的服务,并要求他们确认用于 CSR 的私钥指纹。

关于python - 相互 SSL 身份验证 - 客户端和服务器端。 Python -> Django/Twisted/ Tornado ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9842466/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com