Skip to content

Commit cbc84bc

Browse files
committed
Add binary_form argument to get_ssl_certificate.
The default form contains only basic information; the binary form is more complete.
1 parent 2b07385 commit cbc84bc

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tornado/httpserver.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ def request_time(self):
427427
else:
428428
return self._finish_time - self._start_time
429429

430-
def get_ssl_certificate(self):
430+
def get_ssl_certificate(self, binary_form=False):
431431
"""Returns the client's SSL certificate, if any.
432432
433433
To use client certificates, the HTTPServer must have been constructed
@@ -440,12 +440,16 @@ def get_ssl_certificate(self):
440440
cert_reqs=ssl.CERT_REQUIRED,
441441
ca_certs="cacert.crt"))
442442
443-
The return value is a dictionary, see SSLSocket.getpeercert() in
444-
the standard library for more details.
443+
By default, the return value is a dictionary (or None, if no
444+
client certificate is present). If ``binary_form`` is true, a
445+
DER-encoded form of the certificate is returned instead. See
446+
SSLSocket.getpeercert() in the standard library for more
447+
details.
445448
http://docs.python.org/library/ssl.html#sslsocket-objects
446449
"""
447450
try:
448-
return self.connection.stream.socket.getpeercert()
451+
return self.connection.stream.socket.getpeercert(
452+
binary_form=binary_form)
449453
except ssl.SSLError:
450454
return None
451455

0 commit comments

Comments
 (0)