Skip to content

Commit 247bccc

Browse files
committed
csr: use specific error for CSR signature verification failure
1 parent a5a56b4 commit 247bccc

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

rcgen/src/csr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ impl CertificateSigningRequestParams {
105105
let csr = x509_parser::certification_request::X509CertificationRequest::from_der(csr)
106106
.map_err(|_| Error::CouldNotParseCertificationRequest)?
107107
.1;
108-
csr.verify_signature().map_err(|_| Error::RingUnspecified)?;
108+
csr.verify_signature()
109+
.map_err(|_| Error::InvalidRequestSignature)?;
109110
let alg_oid = csr
110111
.signature_algorithm
111112
.algorithm

rcgen/src/error.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ pub enum Error {
1010
CouldNotParseCertificationRequest,
1111
/// The given key pair couldn't be parsed
1212
CouldNotParseKeyPair,
13+
/// The CSR signature is invalid
14+
#[cfg(feature = "x509-parser")]
15+
InvalidRequestSignature,
1316
#[cfg(feature = "x509-parser")]
1417
/// Invalid subject alternative name type
1518
InvalidNameType,
@@ -62,6 +65,8 @@ impl fmt::Display for Error {
6265
)?,
6366
CouldNotParseKeyPair => write!(f, "Could not parse key pair")?,
6467
#[cfg(feature = "x509-parser")]
68+
InvalidRequestSignature => write!(f, "Invalid CSR signature")?,
69+
#[cfg(feature = "x509-parser")]
6570
InvalidNameType => write!(f, "Invalid subject alternative name type")?,
6671
InvalidAsn1String(e) => write!(f, "{e}")?,
6772
InvalidIpAddressOctetLength(actual) => {

0 commit comments

Comments
 (0)