File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -1064,6 +1064,13 @@ impl X509NameRef {
1064
1064
Ok ( cmp. cmp ( & 0 ) )
1065
1065
}
1066
1066
1067
+ /// Copies the name to a new `X509Name`.
1068
+ #[ corresponds( X509_NAME_dup ) ]
1069
+ #[ cfg( any( boringssl, ossl110, libressl270) ) ]
1070
+ pub fn to_owned ( & self ) -> Result < X509Name , ErrorStack > {
1071
+ unsafe { cvt_p ( ffi:: X509_NAME_dup ( self . as_ptr ( ) ) ) . map ( |n| X509Name :: from_ptr ( n) ) }
1072
+ }
1073
+
1067
1074
to_der ! {
1068
1075
/// Serializes the certificate into a DER-encoded X509 name structure.
1069
1076
///
Original file line number Diff line number Diff line change @@ -615,6 +615,16 @@ fn test_name_cmp() {
615
615
assert_eq ! ( Ordering :: Greater , subject. try_cmp( issuer) . unwrap( ) ) ;
616
616
}
617
617
618
+ #[ test]
619
+ #[ cfg( any( boringssl, ossl110, libressl270) ) ]
620
+ fn test_name_to_owned ( ) {
621
+ let cert = include_bytes ! ( "../../test/cert.pem" ) ;
622
+ let cert = X509 :: from_pem ( cert) . unwrap ( ) ;
623
+ let name = cert. subject_name ( ) ;
624
+ let copied_name = name. to_owned ( ) . unwrap ( ) ;
625
+ assert_eq ! ( Ordering :: Equal , name. try_cmp( & copied_name) . unwrap( ) ) ;
626
+ }
627
+
618
628
#[ test]
619
629
#[ cfg( any( ossl102, libressl261) ) ]
620
630
fn test_verify_param_set_time_fails_verification ( ) {
You can’t perform that action at this time.
0 commit comments