Advertise HTTP/1.1 for the actual loopback OTLP HTTP upstreams

This commit is contained in:
2026-11-16 13:02:05 +03:00
parent 58e693cd76
commit 5fc30acb1c
2 changed files with 13 additions and 1 deletions
+3 -1
View File
@@ -39,7 +39,9 @@ def role(cert, allowed):
def context(cfg):
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
ctx.set_alpn_protocols(["http/1.1"] if cfg.get("http") else ["h2", "http/1.1"])
# Every active HTTP upstream in this lab speaks HTTP/1.1 on loopback.
# Advertising h2 would make Go clients send HTTP/2 to a plaintext H1 port.
ctx.set_alpn_protocols(["http/1.1"])
ctx.minimum_version = ssl.TLSVersion.TLSv1_2
ctx.load_cert_chain(cfg["cert"], cfg["key"])
if cfg.get("allowed"):
+10
View File
@@ -230,3 +230,13 @@ def test_revocation_existing_connection_before_next_command(tcp_boundary):
except OSError:
data = b""
assert data == b""
def test_alpn_does_not_advertise_unsupported_http2(tcp_boundary):
context = client("lb")
context.set_alpn_protocols(["h2", "http/1.1"])
with socket.create_connection(("127.0.0.1", tcp_boundary[0]), timeout=2) as raw:
with context.wrap_socket(raw, server_hostname="api") as conn:
assert conn.selected_alpn_protocol() == "http/1.1"
conn.sendall(b"http1-upstream")
assert conn.recv(1024) == b"http1-upstream"