Skip to content

Commit

Permalink
Fix deprecation warning yielded by Cryptography (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ousret authored Feb 3, 2024
1 parent cdf7324 commit 0c7efa9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Release History
===============

3.4.6 (2024-02-03)
------------------

**Fixed**
- Unmatched filter for deprecation warning yielded by Cryptography due to some legacy CA available in Windows having a negative serial number.

3.4.5 (2024-02-02)
------------------

Expand Down
4 changes: 2 additions & 2 deletions docs/user/authentication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ You must provide the user and pass into the DNS url as such::
from niquests import Session

with Session(resolver="doh://user:[email protected]") as s:
resp = s.get("pie.dev/get")
resp = s.get("https://pie.dev/get")

Passing a bearer token
----------------------
Expand All @@ -60,7 +60,7 @@ You must provide the token directly into the DNS url as such::
from niquests import Session

with Session(resolver="doh://[email protected]") as s:
resp = s.get("pie.dev/get")
resp = s.get("https://pie.dev/get")

netrc Authentication
~~~~~~~~~~~~~~~~~~~~
Expand Down
8 changes: 4 additions & 4 deletions docs/user/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ Here is a basic example that leverage Google public DNS over HTTPS::
from niquests import Session

with Session(resolver="doh+google://") as s:
resp = s.get("pie.dev/get")
resp = s.get("https://pie.dev/get")

Here, the domain name (**pie.dev**) will be resolved using the provided DNS url.

Expand All @@ -920,7 +920,7 @@ You may specify a list of resolvers to be tested in order::
from niquests import Session

with Session(resolver=["doh+google://", "doh://cloudflare-dns.com"]) as s:
resp = s.get("pie.dev/get")
resp = s.get("https://pie.dev/get")

The second entry ``doh://cloudflare-dns.com`` will only be tested if ``doh+google://`` failed to provide a usable answer.

Expand Down Expand Up @@ -959,10 +959,10 @@ Simply add ``verify=false`` into your DNS url to pursue::
from niquests import Session

with Session(resolver="doh+google://default/?verify=false") as s:
resp = s.get("pie.dev/get")
resp = s.get("https://pie.dev/get")


.. warning:: Doing a ``s.get("pie.dev/get", verify=False)`` does not impact the resolver.
.. warning:: Doing a ``s.get("https://pie.dev/get", verify=False)`` does not impact the resolver.

-----------------------

Expand Down
8 changes: 4 additions & 4 deletions src/niquests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@

# urllib3's DependencyWarnings should be silenced.
warnings.simplefilter("ignore", DependencyWarning)
# Some Microsoft root CAs may use a negative serial number. It is known and safe. They know about it.
warnings.filterwarnings(
"ignore", "Parsed a negative serial number", module="cryptography"
)
# Commonly happen on Windows due to some legacy root CA in
# their trust store. They are aware of it, we silent the warning
# yield by Cryptography to avoid producing undesired noise to end-users.
warnings.filterwarnings("ignore", "Parsed a negative serial number")

# ruff: noqa: E402
from . import utils
Expand Down
4 changes: 2 additions & 2 deletions src/niquests/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
__url__: str = "https://niquests.readthedocs.io"

__version__: str
__version__ = "3.4.5"
__version__ = "3.4.6"

__build__: int = 0x030405
__build__: int = 0x030406
__author__: str = "Kenneth Reitz"
__author_email__: str = "[email protected]"
__license__: str = "Apache-2.0"
Expand Down
7 changes: 6 additions & 1 deletion src/niquests/extensions/_ocsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ def _infer_issuer_from(certificate: Certificate) -> Certificate | None:
if isinstance(der_cert, Certificate):
possible_issuer = der_cert
else:
possible_issuer = load_der_x509_certificate(der_cert)
try:
possible_issuer = load_der_x509_certificate(der_cert)
except (
ValueError
): # Defensive: mitigation against future Cryptography evolutions
continue

# detect cryptography old build
if not hasattr(certificate, "verify_directly_issued_by"):
Expand Down

0 comments on commit 0c7efa9

Please sign in to comment.