简体   繁体   English

如何使用Python的socketserver.TCPServer强制进行相互身份验证?

[英]How can I enforce mutual authentication using Python's socketserver.TCPServer?

I'd like to expose a simple TCP server written in Python to the internet. 我想将一个用Python编写的简单TCP服务器公开给互联网。 To authenticate clients, I'd like to rely on both client and server certificates. 为了对客户端进行身份验证,我想同时依赖客户端和服务器证书。 Does socketserver.TCPServer support this mode by default? 默认情况下,socketserver.TCPServer是否支持此模式? If not, can you suggest how to extend the server to implement mutual authentication? 如果没有,您可以建议如何扩展服务器以实现相互身份验证吗?

The default library doesn't handle secure sockets (SSL/TLS). 默认库不处理安全套接字(SSL / TLS)。 Assuming you want to use that specific library no matter what, here's another discussion that shows a way to do it using the OpenSSL libraries . 假设无论如何您都想使用该特定的库, 这是另一个讨论,它显示了使用OpenSSL库执行此操作的方法

If you want to write a server application, you might want to use Twisted, an event-oriented framework for writing network applications in Python. 如果要编写服务器应用程序,则可能要使用Twisted,这是一个面向事件的框架,用于用Python编写网络应用程序。 Here's the relevant documentation on how to enable SSL for a TCP server . 这是有关如何为TCP服务器启用SSL的相关文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM