1{ lib
2, stdenv
3, buildPythonPackage
4, fetchPypi
5, openssl
6, cryptography
7, pytestCheckHook
8, pretend
9, sphinxHook
10, sphinx-rtd-theme
11, flaky
12}:
13
14buildPythonPackage rec {
15 pname = "pyopenssl";
16 version = "23.2.0";
17 format = "setuptools";
18
19 src = fetchPypi {
20 pname = "pyOpenSSL";
21 inherit version;
22 hash = "sha256-J2+TH1WkUufeppxxc+mE6ypEB85BPJGKo0tV+C+bi6w=";
23 };
24
25 outputs = [
26 "out"
27 "dev"
28 "doc"
29 ];
30
31 nativeBuildInputs = [
32 openssl
33 sphinxHook
34 sphinx-rtd-theme
35 ];
36
37 postPatch = ''
38 # remove cryptography pin
39 sed -i "/cryptography/ s/,<[0-9]*//g" setup.py
40 '';
41
42 propagatedBuildInputs = [
43 cryptography
44 ];
45
46 nativeCheckInputs = [
47 flaky
48 pretend
49 pytestCheckHook
50 ];
51
52 __darwinAllowLocalNetworking = true;
53
54 preCheck = ''
55 export LANG="en_US.UTF-8"
56 '';
57
58 disabledTests = [
59 # https://github.com/pyca/pyopenssl/issues/692
60 # These tests, we disable always.
61 "test_set_default_verify_paths"
62 "test_fallback_default_verify_paths"
63 # https://github.com/pyca/pyopenssl/issues/768
64 "test_wantWriteError"
65 # https://github.com/pyca/pyopenssl/issues/1043
66 "test_alpn_call_failure"
67 ] ++ lib.optionals (lib.hasPrefix "libressl" openssl.meta.name) [
68 # https://github.com/pyca/pyopenssl/issues/791
69 # These tests, we disable in the case that libressl is passed in as openssl.
70 "test_op_no_compression"
71 "test_npn_advertise_error"
72 "test_npn_select_error"
73 "test_npn_client_fail"
74 "test_npn_success"
75 "test_use_certificate_chain_file_unicode"
76 "test_use_certificate_chain_file_bytes"
77 "test_add_extra_chain_cert"
78 "test_set_session_id_fail"
79 "test_verify_with_revoked"
80 "test_set_notAfter"
81 "test_set_notBefore"
82 ] ++ lib.optionals (lib.versionAtLeast (lib.getVersion openssl.name) "1.1") [
83 # these tests are extremely tightly wed to the exact output of the openssl cli tool, including exact punctuation.
84 "test_dump_certificate"
85 "test_dump_privatekey_text"
86 "test_dump_certificate_request"
87 "test_export_text"
88 ] ++ lib.optionals stdenv.is32bit [
89 # https://github.com/pyca/pyopenssl/issues/974
90 "test_verify_with_time"
91 ];
92
93 meta = with lib; {
94 description = "Python wrapper around the OpenSSL library";
95 homepage = "https://github.com/pyca/pyopenssl";
96 changelog = "https://github.com/pyca/pyopenssl/blob/${version}/CHANGELOG.rst";
97 license = licenses.asl20;
98 maintainers = with maintainers; [ ];
99 };
100}