Loading openssl-sys/src/handwritten/x509.rs +4 −0 Original line number Diff line number Diff line Loading @@ -633,3 +633,7 @@ extern "C" { pub fn X509_CRL_cmp(a: *const X509_CRL, b: *const X509_CRL) -> c_int; pub fn X509_CRL_match(a: *const X509_CRL, b: *const X509_CRL) -> c_int; } extern "C" { pub fn X509_print(bio: *mut BIO, x509: *mut X509) -> c_int; } openssl/src/x509/mod.rs +7 −0 Original line number Diff line number Diff line Loading @@ -580,6 +580,13 @@ impl X509Ref { to_der, ffi::i2d_X509 } to_pem! { /// Converts the certificate to human readable text. #[corresponds(X509_print)] to_text, ffi::X509_print } } impl ToOwned for X509Ref { Loading openssl/src/x509/tests.rs +26 −0 Original line number Diff line number Diff line Loading @@ -476,3 +476,29 @@ fn test_load_subject_der() { ]; X509Name::from_der(SUBJECT_DER).unwrap(); } #[test] fn test_convert_to_text() { let cert = include_bytes!("../../test/cert.pem"); let cert = X509::from_pem(cert).unwrap(); const SUBSTRINGS: &[&str] = &[ "Certificate:\n", "Serial Number:", "Signature Algorithm:", "Issuer: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd\n", "Subject: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd, CN=foobar.com\n", "Subject Public Key Info:", ]; let text = String::from_utf8(cert.to_text().unwrap()).unwrap(); for substring in SUBSTRINGS { assert!( text.contains(substring), "{:?} not found inside {}", substring, text ); } } Loading
openssl-sys/src/handwritten/x509.rs +4 −0 Original line number Diff line number Diff line Loading @@ -633,3 +633,7 @@ extern "C" { pub fn X509_CRL_cmp(a: *const X509_CRL, b: *const X509_CRL) -> c_int; pub fn X509_CRL_match(a: *const X509_CRL, b: *const X509_CRL) -> c_int; } extern "C" { pub fn X509_print(bio: *mut BIO, x509: *mut X509) -> c_int; }
openssl/src/x509/mod.rs +7 −0 Original line number Diff line number Diff line Loading @@ -580,6 +580,13 @@ impl X509Ref { to_der, ffi::i2d_X509 } to_pem! { /// Converts the certificate to human readable text. #[corresponds(X509_print)] to_text, ffi::X509_print } } impl ToOwned for X509Ref { Loading
openssl/src/x509/tests.rs +26 −0 Original line number Diff line number Diff line Loading @@ -476,3 +476,29 @@ fn test_load_subject_der() { ]; X509Name::from_der(SUBJECT_DER).unwrap(); } #[test] fn test_convert_to_text() { let cert = include_bytes!("../../test/cert.pem"); let cert = X509::from_pem(cert).unwrap(); const SUBSTRINGS: &[&str] = &[ "Certificate:\n", "Serial Number:", "Signature Algorithm:", "Issuer: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd\n", "Subject: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd, CN=foobar.com\n", "Subject Public Key Info:", ]; let text = String::from_utf8(cert.to_text().unwrap()).unwrap(); for substring in SUBSTRINGS { assert!( text.contains(substring), "{:?} not found inside {}", substring, text ); } }