TLS ALPN in Python 2.7

2019-09-18 15:18发布

I'm working on some HTTP/2 client and I want to add SSL support. According to the RFC, the negotiation on the protocol is made using the ALPN protocol. Is there an implementation of ALPN in python 2.7?

(I know there are HTTP/2 client implementations, but I want to write it myself)

Thanks!

1条回答
forever°为你锁心
2楼-- · 2019-09-18 15:47

Please use the documentation and simply search for "alpn". It is well documented, like:

SSLContext.set_alpn_protocols(protocols)

Specify which protocols the socket should advertise during the SSL/TLS handshake. It should be a list of ASCII strings, like ['http/1.1', 'spdy/2'], ordered by preference. The selection of a protocol will happen during the handshake, and will play out according to RFC 7301. After a successful handshake, the SSLSocket.selected_alpn_protocol() method will return the agreed-upon protocol.

查看更多
登录 后发表回答