summaryrefslogtreecommitdiff
path: root/src/OpenSSL/SSL.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2017-11-20 09:04:08 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2017-11-20 22:04:08 +0800
commit4aa52c33d3ee51c632e0e1e10cafb7745fd1028c (patch)
tree159a024ec63fa6df8405fec938289b0cec364d98 /src/OpenSSL/SSL.py
parentc3697ad289dc011692591246e8d6d341f37da298 (diff)
downloadpyopenssl-4aa52c33d3ee51c632e0e1e10cafb7745fd1028c.tar.gz
Don't use things after they're freed...duh (#709)
* Don't use things after they're freed...duh * changelog * more details
Diffstat (limited to 'src/OpenSSL/SSL.py')
-rw-r--r--src/OpenSSL/SSL.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/OpenSSL/SSL.py b/src/OpenSSL/SSL.py
index 667131b..39b7bdc 100644
--- a/src/OpenSSL/SSL.py
+++ b/src/OpenSSL/SSL.py
@@ -1957,9 +1957,7 @@ class Connection(object):
"""
cert = _lib.SSL_get_peer_certificate(self._ssl)
if cert != _ffi.NULL:
- pycert = X509.__new__(X509)
- pycert._x509 = _ffi.gc(cert, _lib.X509_free)
- return pycert
+ return X509._from_raw_x509_ptr(cert)
return None
def get_peer_cert_chain(self):
@@ -1977,8 +1975,7 @@ class Connection(object):
for i in range(_lib.sk_X509_num(cert_stack)):
# TODO could incref instead of dup here
cert = _lib.X509_dup(_lib.sk_X509_value(cert_stack, i))
- pycert = X509.__new__(X509)
- pycert._x509 = _ffi.gc(cert, _lib.X509_free)
+ pycert = X509._from_raw_x509_ptr(cert)
result.append(pycert)
return result