This repository was archived by the owner on Jan 13, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +10
-6
lines changed
Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 55
66Objects that build hyper's connection-level HTTP/2 abstraction.
77"""
8- from ..tls import wrap_socket
8+ from ..tls import wrap_socket , H2_NPN_PROTOCOLS
99from .hpack_compat import Encoder , Decoder
1010from .stream import Stream
1111from .frame import (
@@ -201,7 +201,10 @@ def connect(self):
201201 """
202202 if self ._sock is None :
203203 sock = socket .create_connection ((self .host , self .port ), 5 )
204- sock = wrap_socket (sock , self .host )
204+
205+ sock , proto = wrap_socket (sock , self .host )
206+ assert proto in H2_NPN_PROTOCOLS
207+
205208 self ._sock = BufferedSocket (sock , self .network_buffer_size )
206209
207210 # We need to send the connection header immediately on this
Original file line number Diff line number Diff line change @@ -40,17 +40,18 @@ def wrap_socket(sock, server_hostname):
4040 if _context .check_hostname : # pragma: no cover
4141 ssl .match_hostname (ssl_sock .getpeercert (), server_hostname )
4242
43+ proto = ''
4344 with ignore_missing ():
44- assert ssl_sock .selected_npn_protocol () in H2_NPN_PROTOCOLS
45+ proto = ssl_sock .selected_npn_protocol ()
4546
46- return ssl_sock
47+ return ( ssl_sock , proto )
4748
4849
4950def _init_context ():
5051 """
5152 Creates the singleton SSLContext we use.
5253 """
53- context = ssl .SSLContext (ssl .PROTOCOL_TLSv1_2 )
54+ context = ssl .SSLContext (ssl .PROTOCOL_SSLv23 )
5455 context .set_default_verify_paths ()
5556 context .load_verify_locations (cafile = cert_loc )
5657 context .verify_mode = ssl .CERT_REQUIRED
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ def _start_server(self):
5151 sock = socket .socket (socket .AF_INET6 )
5252 if sys .platform != 'win32' :
5353 sock .setsockopt (socket .SOL_SOCKET , socket .SO_REUSEADDR , 1 )
54- sock = self .cxt .wrap_socket (sock , server_side = True )
54+ sock , proto = self .cxt .wrap_socket (sock , server_side = True )
5555 sock .bind ((self .host , 0 ))
5656 self .port = sock .getsockname ()[1 ]
5757
You can’t perform that action at this time.
0 commit comments