This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author theandrew168
Recipients alex, christian.heimes, docs@python, dstufft, janssen, njs, theandrew168
Date 2021-03-21.20:15:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1616357715.09.0.4079207853.issue43582@roundup.psfhosted.org>
In-reply-to
Content
Yea, I noticed that through some of my digging. The ALPN callback is used to implement SSLContext.set_alpn_protocols() but full control of the callback isn't exposed. Aside from adjusting how the ALPN callback used, do you know of any other way to swap contexts once the selected ALPN proto is known but not before it's too late? As I said before, I'm not super familiar with Python / OpenSSL internals but maybe overriding SSLSocket.do_handshake() would suffice? I don't want this issue to get too far off track.

I'm still doing research on how I'd go about drafting and submitting a formal patch here on the issue tracker. I'm new to this process but definitely want to help out as much as I can.

Here's my current idea for how to adjust the documentation given the current behavior / capabilities.

CURRENT:
Due to the early negotiation phase of the TLS connection, only limited methods and attributes are usable like SSLSocket.selected_alpn_protocol() and SSLSocket.context. SSLSocket.getpeercert(), SSLSocket.getpeercert(), SSLSocket.cipher() and SSLSocket.compress() methods require that the TLS connection has progressed beyond the TLS Client Hello and therefore will not contain return meaningful values nor can they be called safely.

REVISED:
Based on the value of `sni_name`, a new SSLContext can be created and attached to the current SSLSocket. Due to the early negotiation phase of the TLS connection, only the Client Hello will have occurred by the time this callback is called. Methods and attributes such as SSLSocket.selected_alpn_protocol(), SSLSocket.getpeercert(), SSLSocket.cipher(), and SSLSocket.compress() require that the TLS connection has progressed beyond the TLS Client Hello and therefore will not contain return meaningful values nor can they be called safely.
History
Date User Action Args
2021-03-21 20:15:15theandrew168setrecipients: + theandrew168, janssen, christian.heimes, alex, njs, docs@python, dstufft
2021-03-21 20:15:15theandrew168setmessageid: <1616357715.09.0.4079207853.issue43582@roundup.psfhosted.org>
2021-03-21 20:15:15theandrew168linkissue43582 messages
2021-03-21 20:15:15theandrew168create