File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed
openssl-sys/src/handwritten Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -311,6 +311,7 @@ extern "C" {
311311 pub fn X509_get_version ( x : * const X509 ) -> c_long ;
312312 pub fn X509_set_serialNumber ( x : * mut X509 , sn : * mut ASN1_INTEGER ) -> c_int ;
313313 pub fn X509_get_serialNumber ( x : * mut X509 ) -> * mut ASN1_INTEGER ;
314+ pub fn X509_alias_get0 ( x : * mut X509 , len : * mut c_int ) -> * mut c_uchar ;
314315}
315316const_ptr_api ! {
316317 extern "C" {
Original file line number Diff line number Diff line change @@ -304,9 +304,20 @@ mod test {
304304 let parsed = pkcs12. parse2 ( "mypass" ) . unwrap ( ) ;
305305
306306 assert_eq ! (
307- hex:: encode( parsed. cert. unwrap( ) . digest( MessageDigest :: sha1( ) ) . unwrap( ) ) ,
307+ hex:: encode(
308+ parsed
309+ . cert
310+ . as_ref( )
311+ . unwrap( )
312+ . digest( MessageDigest :: sha1( ) )
313+ . unwrap( )
314+ ) ,
308315 "59172d9313e84459bcff27f967e79e6e9217e584"
309316 ) ;
317+ assert_eq ! (
318+ parsed. cert. as_ref( ) . unwrap( ) . alias( ) ,
319+ Some ( b"foobar.com" as & [ u8 ] )
320+ ) ;
310321
311322 let chain = parsed. ca . unwrap ( ) ;
312323 assert_eq ! ( chain. len( ) , 1 ) ;
Original file line number Diff line number Diff line change @@ -649,6 +649,22 @@ impl X509Ref {
649649 }
650650 }
651651
652+ /// Returns this certificate's "alias". This field is populated by
653+ /// OpenSSL in some situations -- specifically OpenSSL will store a
654+ /// PKCS#12 `friendlyName` in this field.
655+ #[ corresponds( X509_alias_get0 ) ]
656+ pub fn alias ( & self ) -> Option < & [ u8 ] > {
657+ unsafe {
658+ let mut len = 0 ;
659+ let ptr = ffi:: X509_alias_get0 ( self . as_ptr ( ) , & mut len) ;
660+ if ptr. is_null ( ) {
661+ None
662+ } else {
663+ Some ( slice:: from_raw_parts ( ptr, len as usize ) )
664+ }
665+ }
666+ }
667+
652668 to_pem ! {
653669 /// Serializes the certificate into a PEM-encoded X509 structure.
654670 ///
You can’t perform that action at this time.
0 commit comments