Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
from circuits import Component, Debugger from circuits.net.sockets import TCPServer, write from circuits.net.events import starttls class TLSEchoServer(Component): def init(self, bind): self.transport = TCPServer(bind, certfile="/circuits/tests/net/cert.pem", ).register(self) def connect(self, sock, foo, bar): self.fire(write(sock, b'* OK [CAPABILITY STARTTLS] Dovecot ready.\r\n')) def read(self, sock, data): if data.strip().upper() == b". STARTTLS": yield self.fire(write(sock, b'. OK Begin TLS negotiation now.')) self.fire(starttls(sock)) return if data.strip() == b'. CAPABILITY': self.fire(write(sock, b'* CAPABILITY STARTTLS \r\n. OK Pre-login capabilities listed, post-login capabilities have more.\r\n')) else: self.fire(write(sock, b'Thanks for TLS encrypting! You wrote: %r' % (data,))) (TLSEchoServer(("0.0.0.0", 8000)) + Debugger()).run() $ openssl s_client -connect localhost:8000 -starttls imap
- Loading branch information
Showing
2 changed files
with
73 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters