MCPcopy Index your code
hub / github.com/RustPython/RustPython / apply_alpn_with_fallback

Function apply_alpn_with_fallback

crates/stdlib/src/ssl/compat.rs:853–858  ·  view source on GitHub ↗

Apply ALPN protocols OpenSSL 1.1.0f+ allows ALPN negotiation to fail without aborting handshake. rustls follows RFC 7301 strictly and rejects connections with no matching protocol. To emulate OpenSSL behavior, we add a special fallback protocol (null byte).

(config_alpn: &mut Vec<Vec<u8>>, alpn_protocols: &[Vec<u8>])

Source from the content-addressed store, hash-verified

851/// rustls follows RFC 7301 strictly and rejects connections with no matching protocol.
852/// To emulate OpenSSL behavior, we add a special fallback protocol (null byte).
853fn apply_alpn_with_fallback(config_alpn: &mut Vec<Vec<u8>>, alpn_protocols: &[Vec<u8>]) {
854 if !alpn_protocols.is_empty() {
855 *config_alpn = alpn_protocols.to_vec();
856 config_alpn.push(vec![0u8]); // Add null byte as fallback marker
857 }
858}
859
860/// Create a client TLS configuration
861///

Callers 2

create_server_configFunction · 0.85
create_client_configFunction · 0.85

Calls 3

to_vecMethod · 0.80
is_emptyMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected