Skip to content

Commit 124a013

Browse files
authored
Drop CI for OpenSSL 1.0.2 (pyca#953)
* Drop CI for OpenSSL 1.0.2 * Delete code for coverage reasons * Bump minimum cryptography version
1 parent 669dcc3 commit 124a013

File tree

8 files changed

+15
-95
lines changed

8 files changed

+15
-95
lines changed

.travis.yml

+1-9
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ jobs:
1616
os: osx
1717
osx_image: xcode11.6
1818
env: TOXENV=py27
19-
- python: "2.7"
20-
env: TOXENV=py27
21-
# we should still test against OpenSSL 1.0.2. Xenial gives us that for now.
22-
dist: xenial
2319
- python: "3.5"
2420
env: TOXENV=py35
2521
- python: "3.6"
@@ -71,13 +67,9 @@ jobs:
7167
- python: "3.7"
7268
env: TOXENV=py37-randomorder
7369

74-
# Make sure we don't break Twisted or urllib3
70+
# Make sure we don't break Twisted
7571
- python: "3.7"
7672
env: TOXENV=py37-twistedMaster
77-
- python: "3.5"
78-
env: TOXENV=py35-urllib3Master
79-
# Somehow urllib3 has trouble with newer distributions
80-
dist: xenial
8173

8274

8375
# Meta

.travis/install_urllib3.sh

-8
This file was deleted.

CHANGELOG.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ The third digit is only for regressions.
1111
Backward-incompatible changes:
1212
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1313

14+
- The minimum ``cryptography`` version is now 3.2.
1415
- Remove deprecated ``OpenSSL.tsafe`` module.
1516
- Removed deprecated ``OpenSSL.SSL.Context.set_npn_advertise_callback``, ``OpenSSL.SSL.Context.set_npn_select_callback``, and ``OpenSSL.SSL.Connection.get_next_proto_negotiated``.
1617
- Drop support for Python 3.4
17-
- Drop support for OpenSSL 1.0.1
18+
- Drop support for OpenSSL 1.0.1 and 1.0.2
1819

1920
Deprecations:
2021
^^^^^^^^^^^^^

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def find_meta(meta):
9494
package_dir={"": "src"},
9595
install_requires=[
9696
# Fix cryptographyMinimum in tox.ini when changing this!
97-
"cryptography>=2.8",
97+
"cryptography>=3.2",
9898
"six>=1.5.2",
9999
],
100100
extras_require={

src/OpenSSL/SSL.py

+6-39
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
X509Name,
2929
X509,
3030
X509Store,
31-
X509StoreContext,
3231
)
3332

3433
__all__ = [
@@ -147,10 +146,7 @@ class _buffer(object):
147146
OP_NO_TLSv1 = _lib.SSL_OP_NO_TLSv1
148147
OP_NO_TLSv1_1 = _lib.SSL_OP_NO_TLSv1_1
149148
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
154150

155151
MODE_RELEASE_BUFFERS = _lib.SSL_MODE_RELEASE_BUFFERS
156152

@@ -202,14 +198,6 @@ class _buffer(object):
202198
SSL_ST_CONNECT = _lib.SSL_ST_CONNECT
203199
SSL_ST_ACCEPT = _lib.SSL_ST_ACCEPT
204200
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-
)
213201

214202
SSL_CB_LOOP = _lib.SSL_CB_LOOP
215203
SSL_CB_EXIT = _lib.SSL_CB_EXIT
@@ -972,11 +960,7 @@ def set_session_id(self, buf):
972960
"""
973961
buf = _text_to_bytes_and_warn("buf", buf)
974962
_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))
980964
== 1
981965
)
982966

@@ -2175,29 +2159,12 @@ def get_verified_chain(self):
21752159
21762160
.. versionadded:: 20.0
21772161
"""
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:
21962165
return None
21972166

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)
22012168

22022169
def want_read(self):
22032170
"""

src/OpenSSL/crypto.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -1603,16 +1603,8 @@ def add_cert(self, cert):
16031603
if not isinstance(cert, X509):
16041604
raise TypeError()
16051605

1606-
# As of OpenSSL 1.1.0i adding the same cert to the store more than
1607-
# once doesn't cause an error. Accordingly, this code now silences
1608-
# the error for OpenSSL < 1.1.0i as well.
1609-
if _lib.X509_STORE_add_cert(self._store, cert._x509) == 0:
1610-
code = _lib.ERR_peek_error()
1611-
err_reason = _lib.ERR_GET_REASON(code)
1612-
_openssl_assert(
1613-
err_reason == _lib.X509_R_CERT_ALREADY_IN_HASH_TABLE
1614-
)
1615-
_lib.ERR_clear_error()
1606+
res = _lib.X509_STORE_add_cert(self._store, cert._x509)
1607+
_openssl_assert(res == 1)
16161608

16171609
def add_crl(self, crl):
16181610
"""

tests/test_ssl.py

+2-11
Original file line numberDiff line numberDiff line change
@@ -2621,17 +2621,8 @@ def test_set_session_wrong_method(self):
26212621
with a context using a different SSL method than the `Connection`
26222622
is using, a `OpenSSL.SSL.Error` is raised.
26232623
"""
2624-
# Make this work on both OpenSSL 1.0.0, which doesn't support TLSv1.2
2625-
# and also on OpenSSL 1.1.0 which doesn't support SSLv3. (SSL_ST_INIT
2626-
# is a way to check for 1.1.0)
2627-
if SSL_ST_INIT is None:
2628-
v1 = TLSv1_2_METHOD
2629-
v2 = TLSv1_METHOD
2630-
elif hasattr(_lib, "SSLv3_method"):
2631-
v1 = TLSv1_METHOD
2632-
v2 = SSLv3_METHOD
2633-
else:
2634-
pytest.skip("Test requires either OpenSSL 1.1.0 or SSLv3")
2624+
v1 = TLSv1_2_METHOD
2625+
v2 = TLSv1_METHOD
26352626

26362627
key = load_privatekey(FILETYPE_PEM, server_key_pem)
26372628
cert = load_certificate(FILETYPE_PEM, server_cert_pem)

tox.ini

+1-16
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extras =
1010
deps =
1111
coverage>=4.2
1212
cryptographyMaster: git+https://github.com/pyca/cryptography.git
13-
cryptographyMinimum: cryptography==2.8
13+
cryptographyMinimum: cryptography==3.2
1414
randomorder: pytest-randomly
1515
setenv =
1616
# Do not allow the executing environment to pollute the test environment
@@ -32,21 +32,6 @@ commands =
3232
python -c "import cryptography; print(cryptography.__version__)"
3333
python -m twisted.trial --reporter=text twisted
3434

35-
[testenv:py35-urllib3Master]
36-
basepython=python3.5
37-
deps =
38-
pyasn1
39-
ndg-httpsclient
40-
passenv = ARCHFLAGS CFLAGS LC_ALL LDFLAGS PATH LD_LIBRARY_PATH TERM TRAVIS_INFRA
41-
whitelist_externals =
42-
rm
43-
commands =
44-
python -c "import OpenSSL.SSL; print(OpenSSL.SSL.SSLeay_version(OpenSSL.SSL.SSLEAY_VERSION))"
45-
python -c "import cryptography; print(cryptography.__version__)"
46-
{toxinidir}/.travis/install_urllib3.sh
47-
pytest urllib3/test
48-
rm -rf ./urllib3
49-
5035
[testenv:flake8]
5136
basepython = python3
5237
deps =

0 commit comments

Comments
 (0)