Skip to content

Commit ad8399e

Browse files
committed
Retain the custom extensions when parsing
1 parent ec64479 commit ad8399e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

rcgen/src/csr.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
Certificate, CertificateParams, Error, Issuer, PublicKeyData, SignatureAlgorithm, SigningKey,
1111
};
1212
#[cfg(feature = "x509-parser")]
13-
use crate::{DistinguishedName, SanType};
13+
use crate::{CustomExtension, DistinguishedName, SanType};
1414
#[cfg(feature = "x509-parser")]
1515
use x509_parser::asn1_rs::Oid;
1616

@@ -208,13 +208,22 @@ impl CertificateSigningRequestParams {
208208
return Err(Error::UnsupportedExtension);
209209
}
210210
},
211-
x509_parser::extensions::ParsedExtension::UnsupportedExtension { oid, value } => {
211+
x509_parser::extensions::ParsedExtension::UnsupportedExtension {
212+
oid,
213+
value,
214+
} => {
212215
valid_fn(oid, value)?;
216+
let oid: Vec<u64> = match oid.iter() {
217+
Some(iter) => iter.collect(),
218+
None => return Err(Error::UnsupportedExtension),
219+
};
220+
let ext = CustomExtension::from_oid_content(&oid, value.to_vec());
221+
params.custom_extensions.push(ext);
213222
},
214223
other => {
215224
dbg!(&other);
216225
return Err(Error::UnsupportedExtension);
217-
}
226+
},
218227
}
219228
}
220229
}

0 commit comments

Comments
 (0)