File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,13 @@ pub struct PublicKey {
19
19
alg : & ' static SignatureAlgorithm ,
20
20
}
21
21
22
+ impl PublicKey {
23
+ /// The algorithm used to generate the public key and sign the CSR.
24
+ pub fn algorithm ( & self ) -> & SignatureAlgorithm {
25
+ self . alg
26
+ }
27
+ }
28
+
22
29
impl PublicKeyData for PublicKey {
23
30
fn alg ( & self ) -> & SignatureAlgorithm {
24
31
self . alg
Original file line number Diff line number Diff line change @@ -364,13 +364,15 @@ mod test_csr {
364
364
365
365
#[ test]
366
366
fn test_csr_roundtrip ( ) {
367
+ let key_pair = KeyPair :: generate ( ) . unwrap ( ) ;
368
+
367
369
// We should be able to serialize a CSR, and then parse the CSR.
368
- _ = CertificateSigningRequestParams :: from_der (
369
- CertificateParams :: default ( )
370
- . serialize_request ( & KeyPair :: generate ( ) . unwrap ( ) )
371
- . unwrap ( )
372
- . der ( ) ,
373
- )
374
- . unwrap ( ) ;
370
+ let csr = CertificateParams :: default ( )
371
+ . serialize_request ( & key_pair )
372
+ . unwrap ( ) ;
373
+ let csrp = CertificateSigningRequestParams :: from_der ( csr . der ( ) ) . unwrap ( ) ;
374
+
375
+ // Ensure algorithms match.
376
+ assert_eq ! ( key_pair . algorithm ( ) , csrp . public_key . algorithm ( ) ) ;
375
377
}
376
378
}
You can’t perform that action at this time.
0 commit comments