GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — asyncio: start_tls() loses buffered data from StreamReader · Issue #142352 · python/cpython Closed Labels 3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug reportBug description:Bug descriptionWhen using This commonly occurs when implementing servers that support the PROXY protocol (e.g., behind HAProxy with
Reproducible exampleServer (server.py)import asyncio import ssl async def handle_client(reader, writer): # Read PROXY protocol header proxy_header = await reader.readline() print(f"PROXY header: {proxy_header}") # Upgrade to TLS - this is where data loss occurs context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) context.load_cert_chain('server.crt', 'server.key') await writer.start_tls(context) print("TLS handshake completed") # Never reached - hangs here data = await reader.read(1024) print(f"Received: {data}") writer.close() await writer.wait_closed() async def main(): server = await asyncio.start_server(handle_client, '127.0.0.1', 8000) async with server: await server.serve_forever() asyncio.run(main()) HAProxy config (haproxy.cfg)Client commandecho "Test message" | openssl s_client -connect 127.0.0.1:5002 Expected behaviorTLS handshake completes and server receives "Test message". Actual behaviorTLS handshake hangs indefinitely because the TLS ClientHello data buffered in Additional contextI have a fix ready with tests and will submit a PR shortly. The fix transfers buffered data from CPython versions tested on:CPython main branch Operating systems tested on:Linux Linked PRsActivity
MetadataMetadataAssigneesLabels3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error Projects
MilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |