Skip to content

Commit

Permalink
ext: fix type leak in custom extension
Browse files Browse the repository at this point in the history
  • Loading branch information
cpu committed Dec 10, 2023
1 parent 98c020f commit 973271c
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions rcgen/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub struct CustomExtension {
/// OID identifying the extension.
///
/// Only one extension with a given OID may appear within a certificate.
pub oid: ObjectIdentifier,
pub oid: Vec<u64>,

/// Criticality of the extension.
///
Expand All @@ -65,29 +65,27 @@ impl CustomExtension {
/// Create a new custom extension with the specified content
pub fn from_oid_content(oid: &[u64], criticality: Criticality, der_value: Vec<u8>) -> Self {
Self {
oid: ObjectIdentifier::from_slice(oid),
oid: oid.to_vec(),
criticality,
der_value,
}
}

/// Obtains the OID components of the extensions, as u64 pieces
pub fn oid_components(&self) -> impl Iterator<Item = u64> + '_ {
self.oid.components().iter().copied()
self.oid.iter().copied()
}

#[cfg(feature = "x509-parser")]
pub(crate) fn from_parsed(
parsed: &x509_parser::prelude::X509Extension<'_>,
) -> Result<Self, Error> {
Ok(CustomExtension {
oid: ObjectIdentifier::from_slice(
&parsed
.oid
.iter()
.ok_or(Error::UnsupportedExtension)?
.collect::<Vec<_>>(),
),
oid: parsed
.oid
.iter()
.ok_or(Error::UnsupportedExtension)?
.collect::<Vec<_>>(),
criticality: if parsed.critical {
Criticality::Critical
} else {
Expand All @@ -100,7 +98,7 @@ impl CustomExtension {

impl Extension for CustomExtension {
fn oid(&self) -> ObjectIdentifier {
self.oid.clone()
ObjectIdentifier::from_slice(&self.oid)
}

fn criticality(&self) -> Criticality {
Expand Down

0 comments on commit 973271c

Please sign in to comment.