Trap the SSL npn protocols attribute error on Python 3.10 (#151)

only set npn if it exists
This commit is contained in:
Scott Phillips 2022-02-01 13:06:10 -05:00 committed by GitHub
parent add8f4852c
commit d89bc052f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 3 deletions

View File

@ -752,10 +752,8 @@ class Channel:
ctx.options |= (_ssl.OP_NO_TLSv1 | _ssl.OP_NO_TLSv1_1)
ctx.set_ciphers('ECDHE+AESGCM:ECDHE+CHACHA20:DHE+AESGCM:DHE+CHACHA20')
ctx.set_alpn_protocols(['h2'])
try:
if _ssl.HAS_NPN:
ctx.set_npn_protocols(['h2'])
except NotImplementedError:
pass
return ctx