Skip to content

Commit 06f15ee

Browse files
committed
Resolve coverage issues.
1 parent 866dffa commit 06f15ee

File tree

3 files changed

+11
-25
lines changed

3 files changed

+11
-25
lines changed

src/rust/cryptography-x509-verification/src/policy/extension.rs

-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use cryptography_x509::{
1414

1515
use crate::{ops::CryptoOps, policy::Policy, ValidationError};
1616

17-
#[derive(Clone)]
1817
pub struct ExtensionPolicy<B: CryptoOps> {
1918
pub(crate) authority_information_access: ExtensionValidator<B>,
2019
pub(crate) authority_key_identifier: ExtensionValidator<B>,
@@ -124,7 +123,6 @@ impl<B: CryptoOps> ExtensionPolicy<B> {
124123
}
125124

126125
/// Represents different criticality states for an extension.
127-
#[derive(Clone)]
128126
pub(crate) enum Criticality {
129127
/// The extension MUST be marked as critical.
130128
Critical,
@@ -153,7 +151,6 @@ type MaybeExtensionValidatorCallback<B> =
153151
fn(&Policy<'_, B>, &Certificate<'_>, Option<&Extension<'_>>) -> Result<(), ValidationError>;
154152

155153
/// Represents different validation states for an extension.
156-
#[derive(Clone)]
157154
pub(crate) enum ExtensionValidator<B: CryptoOps> {
158155
/// The extension MUST NOT be present.
159156
NotPresent,

src/rust/cryptography-x509-verification/src/policy/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@ use cryptography_x509::oid::{
2525
use once_cell::sync::Lazy;
2626

2727
use crate::ops::CryptoOps;
28-
use crate::policy::extension::{ca, common, ee, Criticality, ExtensionValidator};
28+
use crate::policy::extension::{ca, common, ee, Criticality, ExtensionPolicy, ExtensionValidator};
2929
use crate::types::{DNSName, DNSPattern, IPAddress};
3030
use crate::{ValidationError, VerificationCertificate};
3131

32-
pub use crate::policy::extension::ExtensionPolicy;
33-
3432
// RSA key constraints, as defined in CA/B 6.1.5.
3533
static WEBPKI_MINIMUM_RSA_MODULUS: usize = 2048;
3634

src/rust/src/x509/verify.rs

+10-19
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use cryptography_x509::{
77
};
88
use cryptography_x509_verification::{
99
ops::{CryptoOps, VerificationCertificate},
10-
policy::{ExtensionPolicy, Policy, Subject},
10+
policy::{Policy, Subject},
1111
trust_store::Store,
1212
types::{DNSName, IPAddress},
1313
};
@@ -22,7 +22,6 @@ use crate::x509::sign;
2222

2323
use super::parse_general_names;
2424

25-
#[derive(Clone)]
2625
pub(crate) struct PyCryptoOps {}
2726

2827
impl CryptoOps for PyCryptoOps {
@@ -74,8 +73,6 @@ pub(crate) struct PolicyBuilder {
7473
time: Option<asn1::DateTime>,
7574
store: Option<pyo3::Py<PyStore>>,
7675
max_chain_depth: Option<u8>,
77-
ca_ext_policy: Option<ExtensionPolicy<PyCryptoOps>>,
78-
ee_ext_policy: Option<ExtensionPolicy<PyCryptoOps>>,
7976
}
8077

8178
impl PolicyBuilder {
@@ -84,8 +81,6 @@ impl PolicyBuilder {
8481
time: self.time.clone(),
8582
store: self.store.as_ref().map(|s| s.clone_ref(py)),
8683
max_chain_depth: self.max_chain_depth,
87-
ca_ext_policy: self.ca_ext_policy.clone(),
88-
ee_ext_policy: self.ee_ext_policy.clone(),
8984
}
9085
}
9186
}
@@ -98,8 +93,6 @@ impl PolicyBuilder {
9893
time: None,
9994
store: None,
10095
max_chain_depth: None,
101-
ca_ext_policy: None,
102-
ee_ext_policy: None,
10396
}
10497
}
10598

@@ -311,24 +304,22 @@ impl PyClientVerifier {
311304
py_chain.append(c.extra())?;
312305
}
313306

314-
// NOTE: The `unwrap()` cannot fail, since the underlying policy
315-
// enforces the well-formedness of the extension set.
316-
let subjects = match &chain[0]
307+
// NOTE: These `unwrap()`s cannot fail, since the underlying policy
308+
// enforces the presence of a SAN and the well-formedness of the
309+
// extension set.
310+
let leaf_san = &chain[0]
317311
.certificate()
318312
.extensions()
319313
.ok()
320314
.unwrap()
321315
.get_extension(&SUBJECT_ALTERNATIVE_NAME_OID)
322-
{
323-
Some(leaf_san) => {
324-
let leaf_gns = leaf_san.value::<SubjectAlternativeName<'_>>()?;
325-
Some(parse_general_names(py, &leaf_gns)?)
326-
}
327-
None => None,
328-
};
316+
.unwrap();
317+
318+
let leaf_gns = leaf_san.value::<SubjectAlternativeName<'_>>()?;
319+
let py_gns = parse_general_names(py, &leaf_gns)?;
329320

330321
Ok(PyVerifiedClient {
331-
subjects,
322+
subjects: Some(py_gns),
332323
chain: py_chain.unbind(),
333324
})
334325
}

0 commit comments

Comments
 (0)