Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Commit 3955b64

Browse files
committed
Handle unicode strings in PyOpenSSL
1 parent c8f067d commit 3955b64

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

hyper/ssl_compat.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,11 @@ def send(self, data, flags=None):
232232
return self._safe_ssl_call(False, self._conn.send, data, flags)
233233

234234
def selected_npn_protocol(self):
235-
self._conn.get_next_proto_negotiated()
235+
proto = self._conn.get_next_proto_negotiated()
236+
if isinstance(proto, bytes):
237+
return proto.decode('ascii')
238+
239+
return proto
236240

237241
def getpeercert(self):
238242
def resolve_alias(alias):
@@ -316,7 +320,7 @@ def load_cert_chain(self, certfile, keyfile=None, password=None):
316320
self._ctx.use_privatekey_file(keyfile or certfile)
317321

318322
def set_npn_protocols(self, protocols):
319-
self.protocols = protocols
323+
self.protocols = list(map(lambda x:x.encode('ascii'), protocols))
320324

321325
def cb(conn, protos):
322326
# Detect the overlapping set of protocols.

0 commit comments

Comments
 (0)