File tree 3 files changed +29
-1
lines changed
openssl-sys/src/handwritten
3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -311,6 +311,7 @@ extern "C" {
311
311
pub fn X509_get_version ( x : * const X509 ) -> c_long ;
312
312
pub fn X509_set_serialNumber ( x : * mut X509 , sn : * mut ASN1_INTEGER ) -> c_int ;
313
313
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 ;
314
315
}
315
316
const_ptr_api ! {
316
317
extern "C" {
Original file line number Diff line number Diff line change @@ -304,9 +304,20 @@ mod test {
304
304
let parsed = pkcs12. parse2 ( "mypass" ) . unwrap ( ) ;
305
305
306
306
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
+ ) ,
308
315
"59172d9313e84459bcff27f967e79e6e9217e584"
309
316
) ;
317
+ assert_eq ! (
318
+ parsed. cert. as_ref( ) . unwrap( ) . alias( ) ,
319
+ Some ( b"foobar.com" as & [ u8 ] )
320
+ ) ;
310
321
311
322
let chain = parsed. ca . unwrap ( ) ;
312
323
assert_eq ! ( chain. len( ) , 1 ) ;
Original file line number Diff line number Diff line change @@ -649,6 +649,22 @@ impl X509Ref {
649
649
}
650
650
}
651
651
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
+
652
668
to_pem ! {
653
669
/// Serializes the certificate into a PEM-encoded X509 structure.
654
670
///
You can’t perform that action at this time.
0 commit comments