@@ -110,7 +110,7 @@ impl PartialEq for Error {
110110 x509_cert:: builder:: Error :: Signature ( _) ,
111111 x509_cert:: builder:: Error :: Signature ( _) ,
112112 ) => panic ! (
113- "it is impossible to compare the opaque Error contained witin signature::error::Error"
113+ "it is impossible to compare the opaque Error contained within signature::error::Error"
114114 ) ,
115115 _ => false ,
116116 } ,
@@ -205,6 +205,16 @@ where
205205 /// validity, this function offers complete control over these parameters.
206206 /// If this level of control is not needed, use [`CertificateAuthority::new`]
207207 /// instead.
208+ //
209+ // SAFETY: We purposefully allow the `clippy::unwrap_in_result` lint below in this function.
210+ // We can use expect here, because the subject name is defined as a constant which must be able
211+ // to be parsed.
212+ //
213+ // FIXME (@Techassi): This attribute can be used on individual unwrap and expect calls since
214+ // Rust 1.91.0. We should move this attribute to not contaminate an unnecessarily large scope
215+ // once we bump the toolchain to 1.91.0.
216+ // See https://github.com/rust-lang/rust-clippy/pull/15445
217+ #[ allow( clippy:: unwrap_in_result) ]
208218 #[ instrument( name = "create_certificate_authority_with" , skip( signing_key_pair) ) ]
209219 pub fn new_with ( signing_key_pair : S , serial_number : u64 , validity : Duration ) -> Result < Self > {
210220 let serial_number = SerialNumber :: from ( serial_number) ;
@@ -214,7 +224,7 @@ where
214224 // created by us should contain the same subject consisting a common set
215225 // of distinguished names (DNs).
216226 let subject = Name :: from_str ( SDP_ROOT_CA_SUBJECT )
217- . expect ( "the SDP_ROOT_CA_SUBJECT must be a valid subject" ) ;
227+ . expect ( "the constant SDP_ROOT_CA_SUBJECT must be a valid subject" ) ;
218228
219229 let spki_pem = signing_key_pair
220230 . verifying_key ( )
@@ -511,7 +521,7 @@ mod tests {
511521
512522 #[ tokio:: test]
513523 async fn rsa_key_generation ( ) {
514- let mut ca = CertificateAuthority :: new_rsa ( ) . unwrap ( ) ;
524+ let mut ca = CertificateAuthority :: new_rsa ( ) . expect ( "must be able to create RSA-based CA" ) ;
515525 let cert = ca
516526 . generate_rsa_leaf_certificate ( "Product" , "pod" , [ TEST_SAN ] , TEST_CERT_LIFETIME )
517527 . expect (
@@ -523,7 +533,9 @@ mod tests {
523533
524534 #[ tokio:: test]
525535 async fn ecdsa_key_generation ( ) {
526- let mut ca = CertificateAuthority :: new_ecdsa ( ) . unwrap ( ) ;
536+ let mut ca =
537+ CertificateAuthority :: new_ecdsa ( ) . expect ( "must be able to create ECDSA-based CA" ) ;
538+
527539 let cert = ca
528540 . generate_ecdsa_leaf_certificate ( "Product" , "pod" , [ TEST_SAN ] , TEST_CERT_LIFETIME )
529541 . expect (
@@ -535,11 +547,11 @@ mod tests {
535547
536548 fn assert_cert_attributes ( cert : & Certificate ) {
537549 let cert = & cert. tbs_certificate ;
550+ let expected_subject = Name :: from_str ( "CN=Product Certificate for pod" )
551+ . expect ( "constant subject must be valid" ) ;
552+
538553 // Test subject
539- assert_eq ! (
540- cert. subject,
541- Name :: from_str( "CN=Product Certificate for pod" ) . unwrap( )
542- ) ;
554+ assert_eq ! ( cert. subject, expected_subject) ;
543555
544556 // Test SAN extension is present
545557 let extensions = cert. extensions . as_ref ( ) . expect ( "cert must have extensions" ) ;
0 commit comments