Skip to content

Commit 069909a

Browse files
reaperhulkalex
andauthored
repair CI (#1116)
* repair CI * more fixes * pypy39 requires latest cryptography * Apply suggestions from code review Co-authored-by: Alex Gaynor <[email protected]> * use constant * bump minimum version * remove unneeded try * fix Co-authored-by: Alex Gaynor <[email protected]>
1 parent 5a30471 commit 069909a

File tree

7 files changed

+56
-30
lines changed

7 files changed

+56
-30
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@ jobs:
2323
- {VERSION: "3.8", TOXENV: "py38-cryptographyMain"}
2424
- {VERSION: "3.9", TOXENV: "py39-cryptographyMain"}
2525
- {VERSION: "3.10", TOXENV: "py310-cryptographyMain"}
26-
- {VERSION: "pypy-3.7", TOXENV: "pypy3-cryptographyMain"}
2726
- {VERSION: "pypy-3.8", TOXENV: "pypy3-cryptographyMain"}
27+
- {VERSION: "pypy-3.9", TOXENV: "pypy3-cryptographyMain"}
2828
# -cryptographyMinimum
2929
- {VERSION: "3.6", TOXENV: "py36-cryptographyMinimum"}
3030
- {VERSION: "3.7", TOXENV: "py37-cryptographyMinimum"}
3131
- {VERSION: "3.8", TOXENV: "py38-cryptographyMinimum"}
3232
- {VERSION: "3.9", TOXENV: "py39-cryptographyMinimum"}
3333
- {VERSION: "3.10", TOXENV: "py310-cryptographyMinimum"}
34-
- {VERSION: "pypy-3.7", TOXENV: "pypy3-cryptographyMinimum"}
3534
- {VERSION: "pypy-3.8", TOXENV: "pypy3-cryptographyMinimum"}
3635
# Cryptography wheels
3736
- {VERSION: "3.9", TOXENV: "py39-cryptographyMinimum-useWheel"}
@@ -42,7 +41,6 @@ jobs:
4241
- {VERSION: "3.7", TOXENV: "py37-twistedTrunk"}
4342
# Meta
4443
- {VERSION: "3.9", TOXENV: "check-manifest"}
45-
- {VERSION: "3.9", TOXENV: "pypi-readme"}
4644
- {VERSION: "3.9", TOXENV: "flake8"}
4745
- {VERSION: "3.9", TOXENV: "docs"}
4846
name: "${{ matrix.PYTHON.TOXENV }}"
@@ -69,11 +67,11 @@ jobs:
6967
TEST:
7068
- {CONTAINER: "ubuntu-bionic", TOXENV: "py36"}
7169
# cryptographyMain used since there's no wheel
72-
- {CONTAINER: "ubuntu-rolling", TOXENV: "py39-cryptographyMain"}
70+
- {CONTAINER: "ubuntu-rolling", TOXENV: "py310-cryptographyMain"}
7371
name: "${{ matrix.TEST.TOXENV }} on ${{ matrix.TEST.CONTAINER }}"
7472
steps:
7573
- uses: actions/checkout@v3
76-
- run: tox -v
74+
- run: /venv/bin/tox -v
7775
env:
7876
TOXENV: ${{ matrix.TEST.TOXENV }}
7977
RUSTUP_HOME: /root/.rustup

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Backward-incompatible changes:
1111
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
- Remove support for SSLv2 and SSLv3.
14+
- The minimum ``cryptography`` version is now 37.0.2.
1415

1516
Deprecations:
1617
^^^^^^^^^^^^^

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def find_meta(meta):
9696
package_dir={"": "src"},
9797
install_requires=[
9898
# Fix cryptographyMinimum in tox.ini when changing this!
99-
"cryptography>=35.0",
99+
"cryptography>=37.0.2",
100100
],
101101
extras_require={
102102
"test": ["flaky", "pretend", "pytest>=3.0.1"],

src/OpenSSL/SSL.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,24 @@ def _raise_ssl_error(self, ssl, result):
16851685
else:
16861686
# TODO: This is untested.
16871687
_raise_current_error()
1688+
elif error == _lib.SSL_ERROR_SSL and _lib.ERR_peek_error() != 0:
1689+
# In 3.0.x an unexpected EOF no longer triggers syscall error
1690+
# but we want to maintain compatibility so we check here and
1691+
# raise syscall if it is an EOF. Since we're not actually sure
1692+
# what else could raise SSL_ERROR_SSL we check for the presence
1693+
# of the OpenSSL 3 constant SSL_R_UNEXPECTED_EOF_WHILE_READING
1694+
# and if it's not present we just raise an error, which matches
1695+
# the behavior before we added this elif section
1696+
peeked_error = _lib.ERR_peek_error()
1697+
reason = _lib.ERR_GET_REASON(peeked_error)
1698+
if _lib.Cryptography_HAS_UNEXPECTED_EOF_WHILE_READING:
1699+
_openssl_assert(
1700+
reason == _lib.SSL_R_UNEXPECTED_EOF_WHILE_READING
1701+
)
1702+
_lib.ERR_clear_error()
1703+
raise SysCallError(-1, "Unexpected EOF")
1704+
else:
1705+
_raise_current_error()
16881706
elif error == _lib.SSL_ERROR_NONE:
16891707
pass
16901708
else:

tests/test_crypto.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,8 +2077,8 @@ def test_nullbyte_subjectAltName(self):
20772077
b"DNS:altnull.python.org\x00example.com, "
20782078
20792079
b"URI:http://null.python.org\x00http://example.org, "
2080-
b"IP Address:192.0.2.1, IP Address:2001:DB8:0:0:0:0:0:1\n"
2081-
== str(ext).encode("ascii")
2080+
b"IP Address:192.0.2.1, IP Address:2001:DB8:0:0:0:0:0:1"
2081+
== str(ext).encode("ascii").strip()
20822082
)
20832083

20842084
def test_invalid_digest_algorithm(self):
@@ -4090,7 +4090,11 @@ def test_untrusted_self_signed(self):
40904090
with pytest.raises(X509StoreContextError) as exc:
40914091
store_ctx.verify_certificate()
40924092

4093-
assert exc.value.args[0][2] == "self signed certificate"
4093+
# OpenSSL 1.1.x and 3.0.x have different error messages
4094+
assert exc.value.args[0][2] in [
4095+
"self signed certificate",
4096+
"self-signed certificate",
4097+
]
40944098
assert exc.value.certificate.get_subject().CN == "Testing Root CA"
40954099

40964100
def test_invalid_chain_no_root(self):

tests/test_ssl.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -517,15 +517,20 @@ def test_set_cipher_list_no_cipher_match(self, context):
517517
"""
518518
with pytest.raises(Error) as excinfo:
519519
context.set_cipher_list(b"imaginary-cipher")
520-
assert excinfo.value.args == (
521-
[
522-
(
523-
"SSL routines",
524-
"SSL_CTX_set_cipher_list",
525-
"no cipher match",
526-
)
527-
],
528-
)
520+
assert excinfo.value.args[0][0] in [
521+
# 1.1.x
522+
(
523+
"SSL routines",
524+
"SSL_CTX_set_cipher_list",
525+
"no cipher match",
526+
),
527+
# 3.0.x
528+
(
529+
"SSL routines",
530+
"",
531+
"no cipher match",
532+
),
533+
]
529534

530535
def test_load_client_ca(self, context, ca_file):
531536
"""
@@ -564,13 +569,20 @@ def test_set_session_id_fail(self, context):
564569
with pytest.raises(Error) as e:
565570
context.set_session_id(b"abc" * 1000)
566571

567-
assert [
572+
assert e.value.args[0][0] in [
573+
# 1.1.x
568574
(
569575
"SSL routines",
570576
"SSL_CTX_set_session_id_context",
571577
"ssl session id context too long",
572-
)
573-
] == e.value.args[0]
578+
),
579+
# 3.0.x
580+
(
581+
"SSL routines",
582+
"",
583+
"ssl session id context too long",
584+
),
585+
]
574586

575587
def test_set_session_id_unicode(self, context):
576588
"""

tox.ini

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = {pypy,pypy3,py36,py37,py38,py39,py310}{,-cryptographyMain,-cryptographyMinimum}{,-useWheel}{,-randomorder},py37-twistedTrunk,pypi-readme,check-manifest,flake8,docs,coverage-report
2+
envlist = {pypy,pypy3,py36,py37,py38,py39,py310}{,-cryptographyMain,-cryptographyMinimum}{,-useWheel}{,-randomorder},py37-twistedTrunk,check-manifest,flake8,docs,coverage-report
33

44
[testenv]
55
whitelist_externals =
@@ -10,7 +10,7 @@ extras =
1010
deps =
1111
coverage>=4.2
1212
cryptographyMain: git+https://github.com/pyca/cryptography.git
13-
cryptographyMinimum: cryptography==35.0
13+
cryptographyMinimum: cryptography==37.0.2
1414
randomorder: pytest-randomly
1515
setenv =
1616
# Do not allow the executing environment to pollute the test environment
@@ -44,13 +44,6 @@ commands =
4444
black --check .
4545
flake8 .
4646

47-
[testenv:pypi-readme]
48-
deps =
49-
readme_renderer
50-
skip_install = true
51-
commands =
52-
python setup.py check -r -s
53-
5447
[testenv:check-manifest]
5548
deps =
5649
check-manifest

0 commit comments

Comments
 (0)