python / cpython

The Python programming language
https://www.python.org
Other
63.51k stars 30.42k forks source link

ALPN values are not limited to ASCII #91763

Open msoxzw opened 2 years ago

msoxzw commented 2 years ago

According to ALPN Identification Sequence, Python should accordingly not confine ALPN values to ASCII strings in https://github.com/python/cpython/blob/1c8b3b5d66a629258f1db16939b996264a8b9c37/Lib/ssl.py#L565-L575 and https://github.com/python/cpython/blob/1c8b3b5d66a629258f1db16939b996264a8b9c37/Modules/_ssl.c#L2064-L2081

The OpenJDK proposed to use "latin-1" encoding instead of ASCII. However, @jlaine views this workaround as a hack and suggests a more agreeable and maintainable solution https://github.com/aiortc/aioquic/pull/275#issuecomment-1092579877 .

Therefore, which is the more ideal solution, or another better fix?

ronaldoussoren commented 2 years ago

According to RFC7301 the alpn identifier is a sequence of octets without a specified encoding. Most registrations are currently ASCII strings, except for some GREASE values.