Description
Not sure this is the most useful way to record these, but I figure it's better than my just thinking them to myself and then forgetting about them :-). Let me know if they should be moved to some other repo or mailing list or something.
-
IMO the SNI callback should receive the hostname as a bytes object containing the A-label version of the hostname, which for the stdlib wrapper means there should be a call to
.encode("idna")
inpep543_callback
. -
OpenSSL has an annoying thing where when you set a new context from the SNI callback, it only updates some parts of its internal configuration from that context, while ignoring others. Possibly the PEP 543 wrapper callback should work around this by noticing when these other things have changed and updating them manually, if it can, and otherwise error out. (ref)
-
We need at least two kinds of
TLSError
: one that means "definitely an error", and one that means "definitely an error, unless you're running in HTTP-compatibility mode, in which case pretend it's a clean EOF". (For the stdlib wrapper,SSLEOFError
should give you the first one, and everything else the second one.) [Edit: I see that PEP 543 says that'sRaggedEOF
; so then the note here is that_error_converter
needs to doSSLEOFError
→RaggedEOF
.] -
I'm pretty sure the stdlib never raises
SSLZeroReturnError
. Though I can't prove it. But it certainly tries to convert it into areturn b""
internally. -
Writing to a
ssl.MemoryBIO
definitely never returns short. The API allows for the possibility because it might happen for other BIOs, but MemoryBIOs in particular will grow to whatever size they need to, so the nervous comment inreceive_from_network
is unnecessary. -
You do need to watch out though that
MemoryBIO.write(b"")
"helpfully" gets interpreted as indicating an EOF, which may or may not match your API convention forreceive_from_network
. -
Speaking of unbounded memory buffers, it's also impossible to get an
SSLWantWriteError
. I think we should consider removing it from the PEP 543 abstract API. -
You might want to enforce that
do_handshake
is called given https://bugs.python.org/issue30141