Skip to content

Commit 7ef858c

Browse files
committed
Update to latest branch commit
1 parent ad8399e commit 7ef858c

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

rcgen/src/csr.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ use crate::{
1111
};
1212
#[cfg(feature = "x509-parser")]
1313
use crate::{CustomExtension, DistinguishedName, SanType};
14-
#[cfg(feature = "x509-parser")]
15-
use x509_parser::asn1_rs::Oid;
1614

1715
/// A public key, extracted from a CSR
1816
#[derive(Debug, PartialEq, Eq, Hash)]
@@ -97,7 +95,7 @@ impl CertificateSigningRequestParams {
9795
#[cfg(all(feature = "pem", feature = "x509-parser"))]
9896
pub fn from_pem_validated<F>(pem_str: &str, valid_fn: F) -> Result<Self, Error>
9997
where
100-
F: FnMut(&Oid, &[u8]) -> Result<(), Error>,
98+
F: FnMut(&x509_parser::extensions::UnsupportedExtension) -> Result<(), Error>,
10199
{
102100
let csr = pem::parse(pem_str).or(Err(Error::CouldNotParseCertificationRequest))?;
103101
Self::from_der_validated(&csr.contents().into(), valid_fn)
@@ -115,7 +113,7 @@ impl CertificateSigningRequestParams {
115113
/// [`rustls_pemfile::csr()`]: https://docs.rs/rustls-pemfile/latest/rustls_pemfile/fn.csr.html
116114
#[cfg(feature = "x509-parser")]
117115
pub fn from_der(csr: &CertificateSigningRequestDer<'_>) -> Result<Self, Error> {
118-
Self::from_der_validated(csr, |_, _| Ok(()))
116+
Self::from_der_validated(csr, |_| Ok(()))
119117
}
120118

121119
/// Parse a certificate signing request from DER-encoded bytes using the provided
@@ -131,7 +129,7 @@ impl CertificateSigningRequestParams {
131129
mut valid_fn: F,
132130
) -> Result<Self, Error>
133131
where
134-
F: FnMut(&Oid, &[u8]) -> Result<(), Error>,
132+
F: FnMut(&x509_parser::extensions::UnsupportedExtension) -> Result<(), Error>,
135133
{
136134
use crate::KeyUsagePurpose;
137135
use x509_parser::prelude::FromDer;
@@ -208,20 +206,17 @@ impl CertificateSigningRequestParams {
208206
return Err(Error::UnsupportedExtension);
209207
}
210208
},
211-
x509_parser::extensions::ParsedExtension::UnsupportedExtension {
212-
oid,
213-
value,
214-
} => {
215-
valid_fn(oid, value)?;
216-
let oid: Vec<u64> = match oid.iter() {
209+
x509_parser::extensions::ParsedExtension::UnsupportedExtension(val) => {
210+
valid_fn(val)?;
211+
let oid: Vec<u64> = match val.oid.iter() {
217212
Some(iter) => iter.collect(),
218213
None => return Err(Error::UnsupportedExtension),
219214
};
220-
let ext = CustomExtension::from_oid_content(&oid, value.to_vec());
215+
let mut ext = CustomExtension::from_oid_content(&oid, val.value.to_vec());
216+
ext.set_criticality(val.critical);
221217
params.custom_extensions.push(ext);
222218
},
223219
other => {
224-
dbg!(&other);
225220
return Err(Error::UnsupportedExtension);
226221
},
227222
}

rcgen/tests/generic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ mod test_x509_custom_ext {
135135

136136
let csr_params = rcgen::CertificateSigningRequestParams::from_der_validated(
137137
test_cert_csr.der(),
138-
|oid, value| {
139-
if oid != &test_oid || value != &test_ext {
138+
|ext| {
139+
if ext.oid != test_oid || ext.value != &test_ext || !ext.critical {
140140
Err(rcgen::Error::UnsupportedExtension)
141141
} else {
142142
Ok(())

0 commit comments

Comments
 (0)