I want to set the APLN protocols to "h2" and "http/1.1" before the TLS handshake. I am using .set_alpn_protos(). However, my attempt yields an error at runtime:
context.set_alpn_protos(b"\x06h2\x08http/1.1").expect("set ALPN error");
thread 'main' panicked at 'set ALPN error: ErrorStack([])', src/checker/tls/get_tls_info.rs:58:56
I can set them successfully in Python like this:
ssl.set_alpn_protos([b'h2', b'http/1.1'])
What am I doing wrong?
 
                        
From the docs you linked (emphasis mine):
replace
\x06with\x02sinceb"h2"is2bytes not6You could also use something like the following to calculate the wire format from a list similar to pythons: