|
28 | 28 | X509Name, |
29 | 29 | X509, |
30 | 30 | X509Store, |
31 | | - X509StoreContext, |
32 | 31 | ) |
33 | 32 |
|
34 | 33 | __all__ = [ |
@@ -147,10 +146,7 @@ class _buffer(object): |
147 | 146 | OP_NO_TLSv1 = _lib.SSL_OP_NO_TLSv1 |
148 | 147 | OP_NO_TLSv1_1 = _lib.SSL_OP_NO_TLSv1_1 |
149 | 148 | OP_NO_TLSv1_2 = _lib.SSL_OP_NO_TLSv1_2 |
150 | | -try: |
151 | | - OP_NO_TLSv1_3 = _lib.SSL_OP_NO_TLSv1_3 |
152 | | -except AttributeError: |
153 | | - pass |
| 149 | +OP_NO_TLSv1_3 = _lib.SSL_OP_NO_TLSv1_3 |
154 | 150 |
|
155 | 151 | MODE_RELEASE_BUFFERS = _lib.SSL_MODE_RELEASE_BUFFERS |
156 | 152 |
|
@@ -202,14 +198,6 @@ class _buffer(object): |
202 | 198 | SSL_ST_CONNECT = _lib.SSL_ST_CONNECT |
203 | 199 | SSL_ST_ACCEPT = _lib.SSL_ST_ACCEPT |
204 | 200 | SSL_ST_MASK = _lib.SSL_ST_MASK |
205 | | -if _lib.Cryptography_HAS_SSL_ST: |
206 | | - SSL_ST_INIT = _lib.SSL_ST_INIT |
207 | | - SSL_ST_BEFORE = _lib.SSL_ST_BEFORE |
208 | | - SSL_ST_OK = _lib.SSL_ST_OK |
209 | | - SSL_ST_RENEGOTIATE = _lib.SSL_ST_RENEGOTIATE |
210 | | - __all__.extend( |
211 | | - ["SSL_ST_INIT", "SSL_ST_BEFORE", "SSL_ST_OK", "SSL_ST_RENEGOTIATE"] |
212 | | - ) |
213 | 201 |
|
214 | 202 | SSL_CB_LOOP = _lib.SSL_CB_LOOP |
215 | 203 | SSL_CB_EXIT = _lib.SSL_CB_EXIT |
@@ -972,11 +960,7 @@ def set_session_id(self, buf): |
972 | 960 | """ |
973 | 961 | buf = _text_to_bytes_and_warn("buf", buf) |
974 | 962 | _openssl_assert( |
975 | | - _lib.SSL_CTX_set_session_id_context( |
976 | | - self._context, |
977 | | - buf, |
978 | | - len(buf), |
979 | | - ) |
| 963 | + _lib.SSL_CTX_set_session_id_context(self._context, buf, len(buf)) |
980 | 964 | == 1 |
981 | 965 | ) |
982 | 966 |
|
@@ -2175,29 +2159,12 @@ def get_verified_chain(self): |
2175 | 2159 |
|
2176 | 2160 | .. versionadded:: 20.0 |
2177 | 2161 | """ |
2178 | | - if hasattr(_lib, "SSL_get0_verified_chain"): |
2179 | | - # OpenSSL 1.1+ |
2180 | | - cert_stack = _lib.SSL_get0_verified_chain(self._ssl) |
2181 | | - if cert_stack == _ffi.NULL: |
2182 | | - return None |
2183 | | - |
2184 | | - return self._cert_stack_to_list(cert_stack) |
2185 | | - |
2186 | | - pycert = self.get_peer_certificate() |
2187 | | - if pycert is None: |
2188 | | - return None |
2189 | | - |
2190 | | - # Should never be NULL because the peer presented a certificate. |
2191 | | - cert_stack = _lib.SSL_get_peer_cert_chain(self._ssl) |
2192 | | - _openssl_assert(cert_stack != _ffi.NULL) |
2193 | | - |
2194 | | - pystore = self._context.get_cert_store() |
2195 | | - if pystore is None: |
| 2162 | + # OpenSSL 1.1+ |
| 2163 | + cert_stack = _lib.SSL_get0_verified_chain(self._ssl) |
| 2164 | + if cert_stack == _ffi.NULL: |
2196 | 2165 | return None |
2197 | 2166 |
|
2198 | | - pystorectx = X509StoreContext(pystore, pycert) |
2199 | | - pystorectx._chain = cert_stack |
2200 | | - return pystorectx.get_verified_chain() |
| 2167 | + return self._cert_stack_to_list(cert_stack) |
2201 | 2168 |
|
2202 | 2169 | def want_read(self): |
2203 | 2170 | """ |
|
0 commit comments