skeleton lab7 and tasks for grade 3
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
2026-11-21 16:21:47 +03:00
parent 20afc2c790
commit 0b97f77d76
185 changed files with 15590 additions and 154 deletions
+20
View File
@@ -0,0 +1,20 @@
"""Проверка TLS на внутреннем входе каждой реплики."""
import asyncio
import ssl
from uvicorn.protocols.http.h11_impl import H11Protocol
class LoadBalancerProtocol(H11Protocol):
def connection_made(self, transport: asyncio.Transport) -> None:
# TLS уже проверил цепочку и clientAuth. SAN ограничивает роль клиента.
super().connection_made(transport)
tls = transport.get_extra_info("ssl_object")
certificate = tls.getpeercert() if tls else None
if not certificate or ("DNS", "load-balancer") not in certificate.get("subjectAltName", ()):
transport.abort()
def client_context(ca_file: str | None) -> ssl.SSLContext | None:
return ssl.create_default_context(cafile=ca_file) if ca_file else None