python-nss-ng 1.0.4__tar.gz → 1.0.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/Makefile +17 -6
  2. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/PKG-INFO +1 -1
  3. python_nss_ng-1.0.5/REUSE.toml +39 -0
  4. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/doc/ChangeLog +13 -13
  5. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/doc/examples/cert_dump.py +3 -7
  6. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/doc/examples/cert_trust.py +4 -3
  7. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/doc/examples/httplib_example.py +19 -9
  8. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/doc/examples/pbkdf2_example.py +5 -4
  9. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/doc/examples/ssl_cipher_info.py +5 -4
  10. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/doc/examples/ssl_example.py +17 -6
  11. python_nss_ng-1.0.5/doc/examples/ssl_version_range.py +127 -0
  12. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/doc/examples/verify_cert.py +6 -6
  13. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/doc/examples/verify_server.py +2 -5
  14. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/pyproject.toml +91 -6
  15. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/pyrightconfig.json +4 -2
  16. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/__init__.py +5 -5
  17. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/io.pyi +66 -58
  18. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/nss.pyi +496 -120
  19. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/ssl.pyi +75 -46
  20. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/conftest.py +40 -47
  21. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/exceptions.py +11 -7
  22. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/run_tests +3 -0
  23. python_nss_ng-1.0.5/test/setup_certs.py +692 -0
  24. python_nss_ng-1.0.5/test/test_cert_components.py +343 -0
  25. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_cert_request.py +14 -13
  26. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_certificate_advanced.py +54 -63
  27. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_cipher.py +28 -23
  28. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_client_server.py +70 -46
  29. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_deprecations.py +8 -8
  30. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_digest.py +55 -45
  31. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_documentation_accuracy.py +68 -113
  32. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_examples.py +79 -79
  33. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_misc.py +10 -9
  34. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_performance.py +29 -18
  35. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_pkcs12.py +95 -69
  36. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_platform_specific.py +58 -60
  37. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_property_based.py +22 -19
  38. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_secure_logging.py +17 -21
  39. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_security.py +44 -38
  40. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_thread_safety.py +23 -26
  41. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_type_hints.py +64 -62
  42. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_util.py +28 -34
  43. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_zzz_error_messages.py +47 -39
  44. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_zzz_integration.py +29 -38
  45. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_zzz_nonexistent_certs.py +8 -7
  46. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_zzz_nss_context.py +35 -38
  47. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/test_zzz_ocsp.py +15 -12
  48. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/test/util.py +19 -11
  49. python_nss_ng-1.0.5/typings/nss/__init__.pyi +9 -0
  50. python_nss_ng-1.0.5/typings/nss/error.pyi +109 -0
  51. python_nss_ng-1.0.5/typings/nss/io.pyi +551 -0
  52. python_nss_ng-1.0.5/typings/nss/nss.pyi +1423 -0
  53. python_nss_ng-1.0.5/typings/nss/ssl.pyi +681 -0
  54. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/uv.lock +169 -145
  55. python_nss_ng-1.0.4/REUSE.toml +0 -18
  56. python_nss_ng-1.0.4/doc/examples/ssl_version_range.py +0 -120
  57. python_nss_ng-1.0.4/test/setup_certs.py +0 -623
  58. python_nss_ng-1.0.4/test/test_cert_components.py +0 -330
  59. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/.clangd +0 -0
  60. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/CONTRIBUTING.md +0 -0
  61. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/LICENSE +0 -0
  62. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/LICENSE.gpl +0 -0
  63. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/LICENSE.lgpl +0 -0
  64. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/LICENSE.mpl +0 -0
  65. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/LICENSES/Apache-2.0.txt +0 -0
  66. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/LICENSES/MPL-2.0.txt +0 -0
  67. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/MANIFEST.in +0 -0
  68. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/QUICKSTART.md +0 -0
  69. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/README.md +0 -0
  70. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/doc/MAKEFILE_MIGRATION.md +0 -0
  71. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/doc/MANYLINUX_CONFIG.md +0 -0
  72. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/doc/MIGRATION.md +0 -0
  73. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/doc/MUTATION_TESTING.md +0 -0
  74. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/doc/TESTING.md +0 -0
  75. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/doc/get_api +0 -0
  76. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/meson.build +0 -0
  77. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/pyproject.toml +0 -0
  78. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/src/deprecations.py +0 -0
  79. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/src/deprecations.py.meta +0 -0
  80. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/src/nss_context.py +0 -0
  81. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/src/nss_context.py.meta +0 -0
  82. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/src/secure_logging.py +0 -0
  83. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/src/secure_logging.py.meta +0 -0
  84. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/conftest.py +0 -0
  85. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/exceptions.py +0 -0
  86. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/run_tests +0 -0
  87. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/setup_certs.py +0 -0
  88. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_cert_components.py +0 -0
  89. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_cert_request.py +0 -0
  90. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_certificate_advanced.py +0 -0
  91. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_cipher.py +0 -0
  92. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_client_server.py +0 -0
  93. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_deprecations.py +0 -0
  94. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_digest.py +0 -0
  95. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_documentation_accuracy.py +0 -0
  96. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_error_messages.py +0 -0
  97. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_examples.py +0 -0
  98. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_integration.py +0 -0
  99. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_misc.py +0 -0
  100. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_nss_context.py +0 -0
  101. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_ocsp.py +0 -0
  102. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_performance.py +0 -0
  103. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_pkcs12.py +0 -0
  104. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_platform_specific.py +0 -0
  105. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_property_based.py +0 -0
  106. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_secure_logging.py +0 -0
  107. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_security.py +0 -0
  108. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_thread_safety.py +0 -0
  109. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_type_hints.py +0 -0
  110. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/test_util.py +0 -0
  111. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/mutants/test/util.py +0 -0
  112. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/scripts/README.md +0 -0
  113. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/scripts/run-all-tests.sh +0 -0
  114. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/NSPRerrs.h +0 -0
  115. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/SECerrs.h +0 -0
  116. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/SSLerrs.h +0 -0
  117. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/deprecations.py +0 -0
  118. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/nss_context.py +0 -0
  119. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/py_nspr_common.h +0 -0
  120. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/py_nspr_error.c +0 -0
  121. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/py_nspr_error.h +0 -0
  122. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/py_nspr_io.c +0 -0
  123. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/py_nspr_io.h +0 -0
  124. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/py_nss.c +0 -0
  125. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/py_nss.h +0 -0
  126. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/py_shared_doc.h +0 -0
  127. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/py_ssl.c +0 -0
  128. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/py_ssl.h +0 -0
  129. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/py_traceback.h +0 -0
  130. {python_nss_ng-1.0.4 → python_nss_ng-1.0.5}/src/secure_logging.py +0 -0
@@ -4,8 +4,8 @@
4
4
  # Makefile for python-nss-ng
5
5
  # Handles NSS/NSPR dependencies and environment setup for CI builds
6
6
 
7
- .PHONY: help deps-nss deps-test deps-build clean env-setup \
8
- env-github-actions
7
+ .PHONY: help deps-nss deps-test deps-test-system deps-build clean \
8
+ env-setup env-github-actions
9
9
 
10
10
  # Default target
11
11
  help:
@@ -13,7 +13,8 @@ help:
13
13
  @echo ""
14
14
  @echo "Targets:"
15
15
  @echo " deps-nss - Build and install NSS/NSPR from source"
16
- @echo " deps-test - Install test dependencies (meson/ninja)"
16
+ @echo " deps-test-system - Install system test deps (apt only)"
17
+ @echo " deps-test - Install all test dependencies (apt+pip)"
17
18
  @echo " deps-build - Install build dependencies"
18
19
  @echo " env-setup - Set up environment variables"
19
20
  @echo " env-github-actions - Export env vars to GitHub Actions"
@@ -50,13 +51,23 @@ deps-nss:
50
51
  INSTALL_PREFIX=$(INSTALL_PREFIX) \
51
52
  ./.github/scripts/install-nss.sh
52
53
 
53
- # Install test dependencies (for test jobs)
54
- deps-test:
55
- @echo "Installing test dependencies..."
54
+ # Install system-level test dependencies only (apt packages)
55
+ # Use this target in CI *before* actions/setup-python so that pip installs
56
+ # are handled by the correct (hostedtoolcache) Python interpreter.
57
+ deps-test-system:
58
+ @echo "Installing system-level test dependencies..."
56
59
  ifeq ($(PLATFORM),linux)
57
60
  sudo apt-get update || true
58
61
  sudo apt-get install -y meson ninja-build || true
59
62
  endif
63
+
64
+ # Install test dependencies (for test jobs)
65
+ # NOTE: This target runs pip install and should only be called *after*
66
+ # actions/setup-python so that packages are installed into the correct
67
+ # Python environment. If called with the system Python when a different
68
+ # Python will run the tests, imports will fail at test time.
69
+ deps-test: deps-test-system
70
+ @echo "Installing pip test dependencies..."
60
71
  python -m pip install --upgrade pip || true
61
72
  python -m pip install meson-python meson ninja pytest pytest-cov pytest-timeout pytest-xdist hypothesis mypy || true
62
73
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-nss-ng
3
- Version: 1.0.4
3
+ Version: 1.0.5
4
4
  Summary: Python bindings for Network Security Services (NSS) and Netscape Portable Runtime (NSPR)
5
5
  Keywords: nss,nspr,cryptography,ssl,tls,pki,x509,security
6
6
  Author-Email: John Dennis <jdennis@redhat.com>, Matthew Watkins <mwatkins@linuxfoundation.org>
@@ -0,0 +1,39 @@
1
+ version = 1
2
+
3
+ # SPDX-License-Identifier: MPL-2.0
4
+ # SPDX-FileCopyrightText: 2025 The Linux Foundation
5
+
6
+ # Licensing statement required for GHA tests and linting to pass for only this repository
7
+
8
+ [[annotations]]
9
+ path = [
10
+ "test/pki/**",
11
+ "uv.lock",
12
+ "tests/dist/**",
13
+ "img/**",
14
+ "*.lock",
15
+ "test_coverage_report*"
16
+ ]
17
+ SPDX-License-Identifier = "MPL-2.0"
18
+ SPDX-FileCopyrightText = "2025 The Linux Foundation"
19
+
20
+ # Project configuration files and ancillary documentation that
21
+ # cannot easily carry inline SPDX headers.
22
+ [[annotations]]
23
+ path = [
24
+ "pyrightconfig.json",
25
+ "scripts/README.md",
26
+ "doc/ChangeLog",
27
+ ]
28
+ SPDX-License-Identifier = "MPL-2.0"
29
+ SPDX-FileCopyrightText = "Copyright (c) 2010-2025 python-nss-ng contributors"
30
+
31
+ # Mutation testing artifacts produced by mutmut. These are generated
32
+ # files (mutated source copies and metadata) and inherit the license
33
+ # of the source they were produced from.
34
+ [[annotations]]
35
+ path = [
36
+ "mutants/**",
37
+ ]
38
+ SPDX-License-Identifier = "MPL-2.0"
39
+ SPDX-FileCopyrightText = "Copyright (c) 2010-2025 python-nss-ng contributors"
@@ -365,7 +365,7 @@
365
365
  password file and writes hardcoded responses to the stdin of
366
366
  certuil and modutil.
367
367
 
368
- * setup_certs now creates a new sql sytle NSS database (sql:pki)
368
+ * setup_certs now creates a new sql style NSS database (sql:pki)
369
369
 
370
370
  * All tests and examples now load the sql:pki database. Command line
371
371
  arg and variable changed from dbdir to db_name to reflect the
@@ -380,11 +380,11 @@
380
380
  External Changes
381
381
  ----------------
382
382
 
383
- The primary enhancements in this version is support of certifcate
383
+ The primary enhancements in this version is support of certificate
384
384
  validation, OCSP support, and support for the certificate "Authority
385
385
  Information Access" extension.
386
386
 
387
- Enhanced certifcate validation including CA certs can be done via
387
+ Enhanced certificate validation including CA certs can be done via
388
388
  Certificate.verify() or Certificate.is_ca_cert(). When cert
389
389
  validation fails you can now obtain diagnostic information as to why
390
390
  the cert failed to validate. This is encapsulated in the
@@ -575,7 +575,7 @@
575
575
  * For NSS >= 3.13 support CERTDB_TERMINAL_RECORD
576
576
 
577
577
  * You can now query for a specific certificate extension
578
- Certficate.get_extension()
578
+ Certificate.get_extension()
579
579
 
580
580
  * The following classes were added:
581
581
  - RSAGenParams
@@ -594,14 +594,14 @@
594
594
  - SecItem_new_alloc()
595
595
 
596
596
  * The following class constructors were modified to accept
597
- intialization parameters
597
+ initialization parameters
598
598
 
599
599
  - KEYPQGParams (DSA generation parameters)
600
600
 
601
601
  * The PublicKey formatting (i.e. format_lines) was augmented
602
602
  to format DSA keys (formerly it only recognized RSA keys).
603
603
 
604
- * Allow lables and values to be justified when printing objects
604
+ * Allow labels and values to be justified when printing objects
605
605
 
606
606
  * The following were deprecated:
607
607
  - nss.nss.make_line_pairs (replaced by nss.nss.make_line_fmt_tuples)
@@ -609,12 +609,12 @@
609
609
  Deprecated Functionality:
610
610
  -------------------------
611
611
  - make_line_pairs() has been replaced by make_line_fmt_tuples()
612
- because 2-valued tuples were not sufficently general. It is
612
+ because 2-valued tuples were not sufficiently general. It is
613
613
  expected very few programs will have used this function, it's mostly
614
614
  used internally but provided as a support utility.
615
615
 
616
616
  2011-04-22 John Dennis <jdennis@redhat.com> 0.12
617
- * Major new enhancement is additon of PKCS12 support and
617
+ * Major new enhancement is addition of PKCS12 support and
618
618
  AlgorithmID's.
619
619
 
620
620
  * setup.py build enhancements
@@ -757,7 +757,7 @@
757
757
  optional family parameter. This is necessary for utilizing
758
758
  PR_GetAddrInfoByName().
759
759
 
760
- * NetworkAddress initialized via a string paramter are now initalized via
760
+ * NetworkAddress initialized via a string parameter are now initialized via
761
761
  PR_GetAddrInfoByName using family.
762
762
 
763
763
  * Add NetworkAddress.address property to return the address sans the
@@ -785,7 +785,7 @@
785
785
  Deprecated Functionality:
786
786
  -------------------------
787
787
 
788
- * NetworkAddress initialized via a string paramter is now
788
+ * NetworkAddress initialized via a string parameter is now
789
789
  deprecated. AddrInfo should be used instead.
790
790
 
791
791
  * NetworkAddress.set_from_string is now deprecated. AddrInfo should be
@@ -793,7 +793,7 @@
793
793
 
794
794
  * NetworkAddress.hostentry is deprecated. It was a bad idea,
795
795
  NetworkAddress objects can support both IPv4 and IPv6, but a HostEntry
796
- object can only support IPv4. Plus the implementation depdended on
796
+ object can only support IPv4. Plus the implementation depended on
797
797
  being able to perform a reverse DNS lookup which is not always
798
798
  possible.
799
799
 
@@ -806,7 +806,7 @@
806
806
  Internal Changes:
807
807
  -----------------
808
808
 
809
- * Utilize PR_NetAddrFamily() access macro instead of explict access.
809
+ * Utilize PR_NetAddrFamily() access macro instead of explicit access.
810
810
 
811
811
  * Add PRNetAddr_port() utility to hide host vs. network byte order
812
812
  requirements when accessing the port inside a PRNetAddr and simplify
@@ -925,7 +925,7 @@
925
925
  nss.nss.x509_key_usage()
926
926
 
927
927
  * The following class methods and properties were added:
928
- Note: it's a method if the name is suffixed with (), a propety otherwise
928
+ Note: it's a method if the name is suffixed with (), a property otherwise
929
929
  Socket.next()
930
930
  Socket.readlines()
931
931
  Socket.sendall()
@@ -1,6 +1,8 @@
1
1
  # This Source Code Form is subject to the terms of the Mozilla Public
2
2
  # License, v. 2.0. If a copy of the MPL was not distributed with this
3
3
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
+ # SPDX-License-Identifier: MPL-2.0
5
+ # SPDX-FileCopyrightText: Copyright (c) 2010-2025 python-nss-ng contributors
4
6
 
5
7
  '''
6
8
  This example will pretty print the contents of a certificate loaded from a
@@ -15,18 +17,12 @@ print "Certificate is %s" % cert
15
17
  What this example really aims to do is illustrate how to access the various
16
18
  components of a cert.
17
19
  '''
18
- from __future__ import absolute_import
19
- from __future__ import print_function
20
20
 
21
21
  import argparse
22
- import getpass
23
- import os
24
- import sys
25
22
 
26
- from nss.error import NSPRError
27
- import nss.io as io
28
23
  import nss.nss as nss
29
24
 
25
+
30
26
  # -----------------------------------------------------------------------------
31
27
  def print_extension(level, extension):
32
28
  print(nss.indented_format([(level, 'Name: %s' % extension.name),
@@ -1,11 +1,12 @@
1
- from __future__ import absolute_import
2
- from __future__ import print_function
1
+ # SPDX-License-Identifier: MPL-2.0
2
+ # SPDX-FileCopyrightText: Copyright (c) 2010-2025 python-nss-ng contributors
3
+
3
4
 
4
5
  import argparse
5
6
  import sys
6
7
  from typing import Any
8
+
7
9
  import nss.nss as nss
8
- import nss.error as nss_error
9
10
 
10
11
  # Sample program that illustrates how to access certificate trust and/or
11
12
  # modify a certificates trust setting.
@@ -1,21 +1,31 @@
1
- from __future__ import absolute_import
2
- from __future__ import print_function
1
+ # SPDX-License-Identifier: MPL-2.0
2
+ # SPDX-FileCopyrightText: Copyright (c) 2010-2025 python-nss-ng contributors
3
3
 
4
4
  # This Source Code Form is subject to the terms of the Mozilla Public
5
5
  # License, v. 2.0. If a copy of the MPL was not distributed with this
6
6
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
7
 
8
+ # This example predates Python 3 and demonstrates NSS HTTPS usage by
9
+ # subclassing the long-removed ``httplib.HTTP`` class via ``six``. It
10
+ # also performs ``int()`` / host-string coercions that the static
11
+ # type system cannot prove safe. Static type checking of this file
12
+ # is intentionally relaxed so the example can remain available as
13
+ # historical documentation without requiring a full Py3 rewrite.
14
+ #
15
+ # pyright: reportAttributeAccessIssue=false, reportArgumentType=false, reportMissingImports=false
16
+
8
17
  import argparse
9
18
  import errno
10
19
  import getpass
11
- import six.moves.http_client # type: ignore[import-untyped]
12
20
  import logging
13
21
  import sys
22
+
23
+ import six.moves.http_client # type: ignore[import-untyped,unused-ignore]
24
+
14
25
  try:
15
26
  import urlparse
16
27
  except ImportError:
17
28
  import urllib.parse as urlparse
18
- from nss.error import NSPRError
19
29
  import nss.io as io
20
30
  import nss.nss as nss
21
31
  import nss.ssl as ssl
@@ -91,7 +101,7 @@ def auth_certificate_callback(sock, check_sig, is_server, certdb):
91
101
 
92
102
  def password_callback(slot, retry, password):
93
103
  if not retry and password: return password
94
- return getpass.getpass("Enter password for %s: " % slot.token_name);
104
+ return getpass.getpass("Enter password for %s: " % slot.token_name)
95
105
 
96
106
  def handshake_callback(sock):
97
107
  """
@@ -133,7 +143,7 @@ class NSSConnection(six.moves.http_client.HTTPConnection):
133
143
  logging.debug("connect: host=%s port=%s", self.host, self.port)
134
144
  try:
135
145
  addr_info = io.AddrInfo(self.host)
136
- except Exception as e:
146
+ except Exception:
137
147
  logging.error("could not resolve host address \"%s\"", self.host)
138
148
  raise
139
149
 
@@ -148,7 +158,7 @@ class NSSConnection(six.moves.http_client.HTTPConnection):
148
158
  except Exception as e:
149
159
  logging.debug("connect failed: %s (%s)", net_addr, e)
150
160
 
151
- raise IOError(errno.ENOTCONN, "could not connect to %s at port %d" % (self.host, self.port))
161
+ raise OSError(errno.ENOTCONN, "could not connect to %s at port %d" % (self.host, self.port))
152
162
 
153
163
  class NSPRConnection(six.moves.http_client.HTTPConnection):
154
164
  default_port = six.moves.http_client.HTTPConnection.default_port
@@ -164,7 +174,7 @@ class NSPRConnection(six.moves.http_client.HTTPConnection):
164
174
  logging.debug("connect: host=%s port=%s", self.host, self.port)
165
175
  try:
166
176
  addr_info = io.AddrInfo(self.host)
167
- except Exception as e:
177
+ except Exception:
168
178
  logging.error("could not resolve host address \"%s\"", self.host)
169
179
  raise
170
180
 
@@ -179,7 +189,7 @@ class NSPRConnection(six.moves.http_client.HTTPConnection):
179
189
  except Exception as e:
180
190
  logging.debug("connect failed: %s (%s)", net_addr, e)
181
191
 
182
- raise IOError(errno.ENOTCONN, "could not connect to %s at port %d" % (self.host, self.port))
192
+ raise OSError(errno.ENOTCONN, "could not connect to %s at port %d" % (self.host, self.port))
183
193
 
184
194
  class NSSHTTPS(six.moves.http_client.HTTP):
185
195
  _http_vsn = 11
@@ -1,14 +1,15 @@
1
- from __future__ import absolute_import
2
- from __future__ import print_function
1
+ # SPDX-License-Identifier: MPL-2.0
2
+ # SPDX-FileCopyrightText: Copyright (c) 2010-2025 python-nss-ng contributors
3
+
3
4
 
4
5
  import argparse
5
6
  import sys
6
7
  from typing import Any
7
8
 
8
9
  import nss.nss as nss
9
- import nss.error as nss_error
10
+
10
11
  print(sys.path)
11
- import six # type: ignore[import-untyped]
12
+ import six # type: ignore[import-untyped,unused-ignore]
12
13
 
13
14
  #-------------------------------------------------------------------------------
14
15
 
@@ -1,13 +1,14 @@
1
- from __future__ import absolute_import
2
- from __future__ import print_function
1
+ # SPDX-License-Identifier: MPL-2.0
2
+ # SPDX-FileCopyrightText: Copyright (c) 2010-2025 python-nss-ng contributors
3
+
3
4
 
4
5
  import argparse
5
6
  import sys
6
7
 
7
- from nss.error import NSPRError
8
8
  import nss.io as io
9
9
  import nss.nss as nss
10
10
  import nss.ssl as ssl
11
+ from nss.error import NSPRError
11
12
 
12
13
  #-------------------------------------------------------------------------------
13
14
 
@@ -105,7 +106,7 @@ def ssl_connect():
105
106
  try:
106
107
  sock.set_ssl_version_range("tls1.0", "tls1.3")
107
108
  except NSPRError as e:
108
- print("Cannot enable TLS 1.3, {}".format(e))
109
+ print(f"Cannot enable TLS 1.3, {e}")
109
110
 
110
111
  # Provide a callback which notifies us when the SSL handshake is
111
112
  # complete
@@ -1,11 +1,22 @@
1
- from __future__ import absolute_import
2
- from __future__ import print_function
1
+ # SPDX-License-Identifier: MPL-2.0
2
+ # SPDX-FileCopyrightText: Copyright (c) 2010-2025 python-nss-ng contributors
3
+
4
+ # This example predates Python 3 in places: it imports a plain TCP
5
+ # socket via ``io.Socket.import_tcp_socket`` and assigns the result
6
+ # back into an ``ssl.SSLSocket``-typed variable, and similarly mixes
7
+ # ``str`` and ``bytes`` payloads on send/recv. Modernising the code
8
+ # to satisfy strict mypy would change observable behaviour and is
9
+ # out of scope for the tooling sync.
10
+ #
11
+ # mypy: ignore-errors
12
+ # pyright: reportOptionalSubscript=false, reportAttributeAccessIssue=false, reportArgumentType=false, reportCallIssue=false
3
13
 
4
14
  # This Source Code Form is subject to the terms of the Mozilla Public
5
15
  # License, v. 2.0. If a copy of the MPL was not distributed with this
6
16
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
17
 
8
18
  import warnings
19
+
9
20
  warnings.simplefilter( "always", DeprecationWarning)
10
21
 
11
22
  import argparse
@@ -13,10 +24,10 @@ import getpass
13
24
  import os
14
25
  import sys
15
26
 
16
- from nss.error import NSPRError
17
27
  import nss.io as io
18
28
  import nss.nss as nss
19
29
  import nss.ssl as ssl
30
+ from nss.error import NSPRError
20
31
 
21
32
  # -----------------------------------------------------------------------------
22
33
  NO_CLIENT_CERT = 0
@@ -38,7 +49,7 @@ timeout_secs = 3
38
49
 
39
50
  def password_callback(slot, retry, password):
40
51
  if password: return password
41
- return getpass.getpass("Enter password: ");
52
+ return getpass.getpass("Enter password: ")
42
53
 
43
54
  def handshake_callback(sock):
44
55
  print("-- handshake complete --")
@@ -145,7 +156,7 @@ def Client():
145
156
  # Get the IP Address of our server
146
157
  try:
147
158
  addr_info = io.AddrInfo(options.hostname)
148
- except Exception as e:
159
+ except Exception:
149
160
  print("could not resolve host address \"%s\"" % options.hostname)
150
161
  return
151
162
 
@@ -243,7 +254,7 @@ def Server():
243
254
  # Get our certificate and private key
244
255
  server_cert = nss.find_cert_from_nickname(options.server_nickname, options.password)
245
256
  priv_key = nss.find_key_by_any_cert(server_cert, options.password)
246
- server_cert_kea = server_cert.find_kea_type();
257
+ server_cert_kea = server_cert.find_kea_type()
247
258
 
248
259
  print("server cert:\n%s" % server_cert)
249
260
 
@@ -0,0 +1,127 @@
1
+ # SPDX-License-Identifier: MPL-2.0
2
+ # SPDX-FileCopyrightText: Copyright (c) 2010-2025 python-nss-ng contributors
3
+
4
+ """
5
+ In NSS 3.14 the SSL Version Range API was added. This was needed
6
+ to better control the negotiation of SSL and TLS protocols between
7
+ clients and servers. Properly configuring the min and max protocols is
8
+ especially important to prevent protocol downgrade attacks such as
9
+ POODLE. The SSL Version Range API is documented in the nss.ssl module
10
+ documentation as well as the individual functions and methods in
11
+ nss.ssl.
12
+
13
+ This example program illustrates how to query the current and default
14
+ protocol values, how one can get string versions of the protocol
15
+ values to present to a user or use in logging, and how to set the
16
+ protocol values given either a string name or it's matching
17
+ enumeration.
18
+
19
+ This example does not illustrate the proper selection of protocol
20
+ values nor actual SSL/TLS communication.
21
+ """
22
+
23
+ import nss.nss as nss
24
+ import nss.ssl as ssl
25
+
26
+ # Query and print supported SSL Library Versions
27
+
28
+ print(
29
+ "supported ssl version (asString): %s"
30
+ % (ssl.get_supported_ssl_version_range(repr_kind=nss.AsString),)
31
+ )
32
+ print(
33
+ "supported ssl version (asEnumName): %s"
34
+ % (ssl.get_supported_ssl_version_range(repr_kind=nss.AsEnumName),)
35
+ )
36
+ print("supported ssl version (asEnum): %s" % (ssl.get_supported_ssl_version_range(),))
37
+
38
+ # Query and print default SSL Library Versions
39
+
40
+ print()
41
+ print(
42
+ "default ssl version (asString): %s"
43
+ % (ssl.get_default_ssl_version_range(repr_kind=nss.AsString),)
44
+ )
45
+ print(
46
+ "default ssl version (asEnumName): %s"
47
+ % (ssl.get_default_ssl_version_range(repr_kind=nss.AsEnumName),)
48
+ )
49
+ print("default ssl version (asEnum): %s" % (ssl.get_default_ssl_version_range(),))
50
+
51
+ # Equivalent calls on a SSL Socket
52
+
53
+ sock = ssl.SSLSocket()
54
+ sock.set_ssl_option(ssl.SSL_SECURITY, True)
55
+
56
+ print()
57
+ print("Initial Socket version range")
58
+ print("socket ssl version (asString): %s" % (sock.get_ssl_version_range(repr_kind=nss.AsString),))
59
+ print(
60
+ "socket ssl version (asEnumName): %s" % (sock.get_ssl_version_range(repr_kind=nss.AsEnumName),)
61
+ )
62
+ print("socket ssl version (asEnum): %s" % (sock.get_ssl_version_range(),))
63
+
64
+
65
+ # Note, setting the version range can be done either with an
66
+ # enumeration constant (e.g. ssl.SSL_LIBRARY_VERSION_TLS_1_1)
67
+ # or with a friendly name (e.g. 'tls1.1')
68
+
69
+ # Set with enumeration constants
70
+ sock.set_ssl_version_range(ssl.SSL_LIBRARY_VERSION_TLS_1_1, ssl.SSL_LIBRARY_VERSION_TLS_1_2)
71
+
72
+
73
+ print()
74
+ print("Socket version range after setting")
75
+ print("socket ssl version (asString): %s" % (sock.get_ssl_version_range(repr_kind=nss.AsString),))
76
+ print(
77
+ "socket ssl version (asEnumName): %s" % (sock.get_ssl_version_range(repr_kind=nss.AsEnumName),)
78
+ )
79
+ print("socket ssl version (asEnum): %s" % (sock.get_ssl_version_range(),))
80
+
81
+ # Set with friendly names
82
+ ssl.set_default_ssl_version_range("tls1.1", "tls1.2")
83
+
84
+ print()
85
+ print(
86
+ "default ssl version after resetting (asString): %s"
87
+ % (ssl.get_default_ssl_version_range(repr_kind=nss.AsString),)
88
+ )
89
+ print(
90
+ "default ssl version after resetting (asEnumName): %s"
91
+ % (ssl.get_default_ssl_version_range(repr_kind=nss.AsEnumName),)
92
+ )
93
+ print("default ssl version after resetting (asEnum): %s" % (ssl.get_default_ssl_version_range(),))
94
+
95
+ # Illustrate mapping between version names and enumerations.
96
+ # Note, the repr_kind parameter to the get library version functions
97
+ # will also give you the option as to whether an enumerated constant
98
+ # or a name is returned.
99
+
100
+ names = [
101
+ "ssl2",
102
+ "ssl3",
103
+ "tls1.0",
104
+ "tls1.1",
105
+ "tls1.2",
106
+ "tls1.3",
107
+ "SSL_LIBRARY_VERSION_2",
108
+ "SSL_LIBRARY_VERSION_3_0",
109
+ "SSL_LIBRARY_VERSION_TLS_1_0",
110
+ "SSL_LIBRARY_VERSION_TLS_1_1",
111
+ "SSL_LIBRARY_VERSION_TLS_1_2",
112
+ "SSL_LIBRARY_VERSION_TLS_1_3",
113
+ ]
114
+
115
+ print()
116
+ print("Convert to enum name")
117
+ for name in names:
118
+ enum = ssl.ssl_library_version_from_name(name)
119
+ enum_name = ssl.ssl_library_version_name(enum)
120
+ print("name='%s' -> %s (%#06x)" % (name, enum_name, enum))
121
+
122
+ print()
123
+ print("Convert to friendly name")
124
+ for name in names:
125
+ enum = ssl.ssl_library_version_from_name(name)
126
+ enum_name = ssl.ssl_library_version_name(enum, nss.AsString)
127
+ print("name='%s' -> %s (%#06x)" % (name, enum_name, enum))
@@ -1,12 +1,13 @@
1
- from __future__ import absolute_import
2
- from __future__ import print_function
1
+ # SPDX-License-Identifier: MPL-2.0
2
+ # SPDX-FileCopyrightText: Copyright (c) 2010-2025 python-nss-ng contributors
3
+
3
4
 
4
5
  import argparse
5
6
  import sys
6
7
  from typing import Any
7
8
 
8
- import nss.nss as nss
9
9
  import nss.error as nss_error
10
+ import nss.nss as nss
10
11
 
11
12
  # Global variable for command-line options
12
13
  options: Any = None
@@ -279,9 +280,8 @@ def main():
279
280
  if valid:
280
281
  print(indented_output('SUCCESS: cert is approved for', nss.cert_usage_flags(intended_usage)))
281
282
  return 0
282
- else:
283
- print(indented_output('FAIL: cert not approved for', nss.cert_usage_flags(intended_usage ^ approved_usage)))
284
- return 1
283
+ print(indented_output('FAIL: cert not approved for', nss.cert_usage_flags(intended_usage ^ approved_usage)))
284
+ return 1
285
285
 
286
286
  #-------------------------------------------------------------------------------
287
287
  if __name__ == "__main__":
@@ -1,16 +1,13 @@
1
- from __future__ import absolute_import
2
- from __future__ import print_function
1
+ # SPDX-License-Identifier: MPL-2.0
2
+ # SPDX-FileCopyrightText: Copyright (c) 2010-2025 python-nss-ng contributors
3
3
 
4
4
  # This Source Code Form is subject to the terms of the Mozilla Public
5
5
  # License, v. 2.0. If a copy of the MPL was not distributed with this
6
6
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
7
 
8
8
  import argparse
9
- import getpass
10
- import os
11
9
  import sys
12
10
 
13
- from nss.error import NSPRError
14
11
  import nss.io as io
15
12
  import nss.nss as nss
16
13
  import nss.ssl as ssl