diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2017-11-20 09:04:08 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2017-11-20 22:04:08 +0800 |
commit | 4aa52c33d3ee51c632e0e1e10cafb7745fd1028c (patch) | |
tree | 159a024ec63fa6df8405fec938289b0cec364d98 /src/OpenSSL/SSL.py | |
parent | c3697ad289dc011692591246e8d6d341f37da298 (diff) | |
download | pyopenssl-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.py | 7 |
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 |