Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub enum Error {

/// A presented or reference DNS identifier was malformed, potentially
/// containing invalid characters or invalid labels.
MalformedDnsIdentifier,
MalformedDnsIdentifier(DnsNameError),

/// The certificate extensions are malformed.
///
Expand All @@ -149,7 +149,7 @@ pub enum Error {

/// A name constraint was malformed, potentially containing invalid characters or
/// invalid labels.
MalformedNameConstraint,
MalformedNameConstraint(DnsNameError),

/// The maximum number of name constraint comparisons has been reached.
MaximumNameConstraintComparisonsExceeded,
Expand Down Expand Up @@ -302,8 +302,8 @@ impl Error {
Self::MaximumPathDepthExceeded => 61,

// Errors related to malformed data.
Self::MalformedDnsIdentifier => 60,
Self::MalformedNameConstraint => 50,
Self::MalformedDnsIdentifier(_) => 60,
Self::MalformedNameConstraint(_) => 50,
Self::MalformedExtensions | Self::TrailingData(_) => 40,
Self::ExtensionValueInvalid => 30,

Expand Down Expand Up @@ -430,3 +430,23 @@ pub enum DerTypeId {
SubjectUniqueId,
KeyUsageExtension,
}

/// Errors possible when parsing a DNS name.
///
/// This applies when parsing presented names, asserted names, or name constraints.
#[expect(missing_docs)]
#[non_exhaustive]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DnsNameError {
IllegalCharacter(u8),
LabelMustNotBeEmpty,
LabelMustNotEndWithHyphen,
LabelMustNotStartWithHyphen,
LabelTooLong,
LastLabelMustNotBeAllNumeric,
NameMustBeRelative,
NameTooLong,
Truncated,
WildcardAsteriskMustBeAloneInLabel,
WildcardMustPrecedeTwoLabels,
}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub use crl::{OwnedCertRevocationList, OwnedRevokedCert};
pub use der::DerIterator;
pub use end_entity::EndEntityCert;
pub use error::{
DerTypeId, Error, InvalidNameContext, UnsupportedSignatureAlgorithmContext,
DerTypeId, DnsNameError, Error, InvalidNameContext, UnsupportedSignatureAlgorithmContext,
UnsupportedSignatureAlgorithmForPublicKeyContext,
};
pub use rpk_entity::RawPublicKeyEntity;
Expand Down
Loading
Loading