Skip to content

Commit a8915b8

Browse files
authored
Remove deprecated verifier attributes (#12940)
1 parent bb102c7 commit a8915b8

File tree

6 files changed

+16
-102
lines changed

6 files changed

+16
-102
lines changed

docs/x509/verification.rst

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,6 @@ the root of trust:
133133

134134
.. versionadded:: 43.0.0
135135

136-
.. versionchanged:: 45.0.0
137-
``verification_time`` and ``max_chain_depth`` were deprecated and will be
138-
removed in version 46.0.0.
139-
The new ``policy`` property should be used to access these values instead.
140-
141136
A ClientVerifier verifies client certificates.
142137

143138
It contains and describes various pieces of configurable path
@@ -180,12 +175,6 @@ the root of trust:
180175

181176
.. versionadded:: 42.0.0
182177

183-
.. versionchanged:: 45.0.0
184-
``subject``, ``verification_time`` and ``max_chain_depth`` were deprecated and will be
185-
removed in version 46.0.0.
186-
The new ``policy`` property should be used to access these values instead.
187-
188-
189178
A ServerVerifier verifies server certificates.
190179

191180
It contains and describes various pieces of configurable path
@@ -233,7 +222,7 @@ the root of trust:
233222
.. versionadded:: 42.0.0
234223

235224
.. versionchanged:: 45.0.0
236-
Added the ``extension_policies`` method.
225+
Added the ``extension_policies`` method.
237226
Removed the ``new_`` prefix from all parameter names.
238227

239228
A PolicyBuilder provides a builder-style interface for constructing a
@@ -284,11 +273,11 @@ the root of trust:
284273
.. warning::
285274
If the PolicyBuilder will be used to build a :class:`ServerVerifier`, the EE extension policy
286275
`must require` the :class:`~cryptography.x509.SubjectAlternativeName` extension to be present.
287-
All CA extension policies `must require` the :class:`~cryptography.x509.BasicConstraints`
276+
All CA extension policies `must require` the :class:`~cryptography.x509.BasicConstraints`
288277
extension to be present.
289278

290279
:param ExtensionPolicy ca_policy: The CA extension policy to use.
291-
:param ExtensionPolicy ee_policy: The EE extension policy to use.
280+
:param ExtensionPolicy ee_policy: The EE extension policy to use.
292281

293282
:returns: A new instance of :class:`PolicyBuilder`
294283

@@ -337,7 +326,7 @@ the root of trust:
337326

338327
.. staticmethod:: permit_all()
339328

340-
Creates an ExtensionPolicy that does not put any constraints on a certificate's extensions.
329+
Creates an ExtensionPolicy that does not put any constraints on a certificate's extensions.
341330
This can serve as a base for a fully custom extension policy.
342331

343332
:returns: An instance of :class:`ExtensionPolicy`
@@ -371,17 +360,17 @@ the root of trust:
371360
.. method:: may_be_present(extension_type, criticality, validator_cb)
372361

373362
Specifies that the extension identified by `extension_type` is optional.
374-
If it is present, it must conform to the given criticality constraint.
363+
If it is present, it must conform to the given criticality constraint.
375364
An optional validator callback may be provided.
376365

377-
If a validator callback is provided, the callback will be invoked
378-
when :meth:`ClientVerifier.verify` or :meth:`ServerVerifier.verify` is called on a verifier
366+
If a validator callback is provided, the callback will be invoked
367+
when :meth:`ClientVerifier.verify` or :meth:`ServerVerifier.verify` is called on a verifier
379368
that uses the extension policy. For details on the callback signature, see :type:`MaybeExtensionValidatorCallback`.
380369

381370
:param type[ExtensionType] extension_type: A concrete class derived from :type:`~cryptography.x509.ExtensionType`
382371
indicating which extension may be present.
383372
:param Criticality criticality: The criticality of the extension
384-
:param validator_cb: An optional Python callback to validate the extension value.
373+
:param validator_cb: An optional Python callback to validate the extension value.
385374
Must accept extensions of type `extension_type`.
386375
:type validator_cb: :type:`MaybeExtensionValidatorCallback` or None
387376

@@ -392,8 +381,8 @@ the root of trust:
392381
Specifies that the extension identified by `extension_type`` must be present
393382
and conform to the given criticality constraint. An optional validator callback may be provided.
394383

395-
If a validator callback is provided, the callback will be invoked
396-
when :meth:`ClientVerifier.verify` or :meth:`ServerVerifier.verify` is called on a verifier
384+
If a validator callback is provided, the callback will be invoked
385+
when :meth:`ClientVerifier.verify` or :meth:`ServerVerifier.verify` is called on a verifier
397386
that uses the extension policy. For details on the callback signature, see :type:`PresentExtensionValidatorCallback`.
398387

399388
:param type[ExtensionType] extension_type: A concrete class derived from :type:`~cryptography.x509.ExtensionType`
@@ -416,7 +405,7 @@ the root of trust:
416405
The extension must be marked as critical.
417406

418407
.. attribute:: AGNOSTIC
419-
408+
420409
The extension may be marked either as critical or non-critical.
421410

422411
.. attribute:: NON_CRITICAL
@@ -427,7 +416,7 @@ the root of trust:
427416

428417
.. versionadded:: 45.0.0
429418

430-
Represents a policy for certificate verification. Passed to extension validator callbacks and
419+
Represents a policy for certificate verification. Passed to extension validator callbacks and
431420
accessible via :class:`ClientVerifier` and :class:`ServerVerifier`.
432421

433422
.. attribute:: max_chain_depth
@@ -438,7 +427,7 @@ the root of trust:
438427

439428
.. attribute:: subject
440429

441-
The subject used during verification.
430+
The subject used during verification.
442431
Will be None if the verifier is a :class:`ClientVerifier`.
443432

444433
:type: x509.verification.Subject or None
@@ -463,7 +452,7 @@ the root of trust:
463452

464453
.. type:: MaybeExtensionValidatorCallback
465454
:canonical: Callable[[Policy, Certificate, Optional[ExtensionType]], None]
466-
455+
467456
.. versionadded:: 45.0.0
468457

469458

@@ -475,7 +464,7 @@ the root of trust:
475464
:param Policy policy: The verification policy.
476465
:param Certificate certificate: The certificate being verified.
477466
:param ExtensionType or None extension: The extension value or `None` if the extension is not present.
478-
467+
479468
:returns: An extension validator callback must return `None`.
480469
If the validation fails, the validator must raise an exception.
481470

src/cryptography/hazmat/bindings/_rust/x509.pyi

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,6 @@ class ClientVerifier:
277277
@property
278278
def policy(self) -> Policy: ...
279279
@property
280-
def validation_time(self) -> datetime.datetime: ...
281-
@property
282-
def max_chain_depth(self) -> int: ...
283-
@property
284280
def store(self) -> Store: ...
285281
def verify(
286282
self,
@@ -292,12 +288,6 @@ class ServerVerifier:
292288
@property
293289
def policy(self) -> Policy: ...
294290
@property
295-
def subject(self) -> x509.verification.Subject: ...
296-
@property
297-
def validation_time(self) -> datetime.datetime: ...
298-
@property
299-
def max_chain_depth(self) -> int: ...
300-
@property
301291
def store(self) -> Store: ...
302292
def verify(
303293
self,

src/cryptography/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class CryptographyDeprecationWarning(UserWarning):
2626
DeprecatedIn41 = CryptographyDeprecationWarning
2727
DeprecatedIn42 = CryptographyDeprecationWarning
2828
DeprecatedIn43 = CryptographyDeprecationWarning
29-
DeprecatedIn45 = CryptographyDeprecationWarning
3029

3130

3231
# If you're wondering why we don't use `Buffer`, it's because `Buffer` would

src/rust/src/types.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ pub static DEPRECATED_IN_42: LazyPyImport =
4747
LazyPyImport::new("cryptography.utils", &["DeprecatedIn42"]);
4848
pub static DEPRECATED_IN_43: LazyPyImport =
4949
LazyPyImport::new("cryptography.utils", &["DeprecatedIn43"]);
50-
pub static DEPRECATED_IN_45: LazyPyImport =
51-
LazyPyImport::new("cryptography.utils", &["DeprecatedIn45"]);
5250

5351
pub static ENCODING: LazyPyImport = LazyPyImport::new(
5452
"cryptography.hazmat.primitives.serialization",

src/rust/src/x509/verify/mod.rs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use super::parse_general_names;
2020
use crate::backend::keys;
2121
use crate::error::{CryptographyError, CryptographyResult};
2222
use crate::types;
23-
use crate::utils::cstr_from_literal;
2423
use crate::x509::certificate::Certificate as PyCertificate;
2524
use crate::x509::common::{datetime_now, py_to_datetime};
2625
use crate::x509::sign;
@@ -306,25 +305,6 @@ pub(crate) struct PyVerifiedClient {
306305
chain: pyo3::Py<pyo3::types::PyList>,
307306
}
308307

309-
macro_rules! warn_verifier_deprecated_getter {
310-
($py: expr, $class_name: literal, $property_name: literal) => {{
311-
let warning_cls = types::DEPRECATED_IN_45.get($py)?;
312-
let message = cstr_from_literal!(concat!(
313-
"The `",
314-
$property_name,
315-
"` property on `",
316-
$class_name,
317-
"` is deprecated and will be removed in cryptography 46.0.",
318-
" Access via `",
319-
$class_name,
320-
".policy.",
321-
$property_name,
322-
"` instead."
323-
));
324-
pyo3::PyErr::warn($py, &warning_cls, message, 1)
325-
}};
326-
}
327-
328308
#[pyo3::pyclass(
329309
frozen,
330310
name = "ClientVerifier",
@@ -345,18 +325,6 @@ impl PyClientVerifier {
345325

346326
#[pyo3::pymethods]
347327
impl PyClientVerifier {
348-
#[getter]
349-
fn validation_time(&self, py: pyo3::Python<'_>) -> pyo3::PyResult<pyo3::PyObject> {
350-
warn_verifier_deprecated_getter!(py, "ClientVerifier", "validation_time")?;
351-
self.py_policy.get().validation_time(py)
352-
}
353-
354-
#[getter]
355-
fn max_chain_depth(&self, py: pyo3::Python<'_>) -> pyo3::PyResult<u8> {
356-
warn_verifier_deprecated_getter!(py, "ClientVerifier", "max_chain_depth")?;
357-
Ok(self.py_policy.get().max_chain_depth())
358-
}
359-
360328
fn verify(
361329
&self,
362330
py: pyo3::Python<'_>,
@@ -429,24 +397,6 @@ impl PyServerVerifier {
429397

430398
#[pyo3::pymethods]
431399
impl PyServerVerifier {
432-
#[getter]
433-
fn subject(&self, py: pyo3::Python<'_>) -> pyo3::PyResult<pyo3::PyObject> {
434-
warn_verifier_deprecated_getter!(py, "ServerVerifier", "subject")?;
435-
Ok(self.py_policy.get().subject(py))
436-
}
437-
438-
#[getter]
439-
fn validation_time(&self, py: pyo3::Python<'_>) -> pyo3::PyResult<pyo3::PyObject> {
440-
warn_verifier_deprecated_getter!(py, "ServerVerifier", "validation_time")?;
441-
self.py_policy.get().validation_time(py)
442-
}
443-
444-
#[getter]
445-
fn max_chain_depth(&self, py: pyo3::Python<'_>) -> pyo3::PyResult<u8> {
446-
warn_verifier_deprecated_getter!(py, "ServerVerifier", "max_chain_depth")?;
447-
Ok(self.py_policy.get().max_chain_depth())
448-
}
449-
450400
fn verify<'p>(
451401
&self,
452402
py: pyo3::Python<'p>,

tests/x509/verification/test_verification.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import pytest
1212

13-
from cryptography import utils, x509
13+
from cryptography import x509
1414
from cryptography.hazmat._oid import ExtendedKeyUsageOID
1515
from cryptography.x509 import ExtensionType
1616
from cryptography.x509.general_name import DNSName, IPAddress
@@ -99,12 +99,6 @@ def test_builder_pattern(self):
9999
assert verifier.policy.subject == subject
100100
assert verifier.policy.validation_time == now
101101
assert verifier.policy.max_chain_depth == max_chain_depth
102-
with pytest.warns(utils.DeprecatedIn45):
103-
assert verifier.subject == subject
104-
with pytest.warns(utils.DeprecatedIn45):
105-
assert verifier.validation_time == now
106-
with pytest.warns(utils.DeprecatedIn45):
107-
assert verifier.max_chain_depth == max_chain_depth
108102

109103
assert (
110104
verifier.policy.extended_key_usage
@@ -164,12 +158,6 @@ def test_verify(self):
164158
tzinfo=None
165159
)
166160
assert verifier.policy.max_chain_depth == max_chain_depth
167-
with pytest.warns(utils.DeprecatedIn45):
168-
assert verifier.validation_time == validation_time.replace(
169-
tzinfo=None
170-
)
171-
with pytest.warns(utils.DeprecatedIn45):
172-
assert verifier.max_chain_depth == max_chain_depth
173161

174162
assert (
175163
verifier.policy.extended_key_usage

0 commit comments

Comments
 (0)