INNER CODE UNIT · Python

_ALPNSelectHelper

pyca/pyopenssl · src/OpenSSL/SSL.py:507

class _ALPNSelectHelper:
    """
    Wrap a callback such that it can be used as an ALPN selection callback.
    """

    def __init__(self, callback: _ALPNSelectCallback) -> None:
        @wraps(callback)
        def wrapper(ssl, out, outlen, in_, inlen, arg):  # type: ignore[no-untyped-def]
            conn = Connection._reverse_mapping[ssl]
            try:
                # The string passed to us is made up of multiple
                # length-prefixed bytestrings. We need to split that into a
                # list.
                instr = _ffi.buffer(in_, inlen)[:]
                protolist = []
                while instr:
                    encoded_len = instr[0]
                    proto = instr[1 : encoded_len + 1]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…