diff options
author | Daniel Abramov <dabramov@snapview.de> | 2019-06-12 15:10:05 +0200 |
---|---|---|
committer | Daniel Abramov <dabramov@snapview.de> | 2019-06-12 16:48:16 +0200 |
commit | fab6ea4727dd70c36989f21d41ef21793eaa4006 (patch) | |
tree | 196932e3235fd59a256607737f417001369b0313 | |
parent | ed966a09ac723c0437f7ab1e6a1a7527b1461307 (diff) | |
download | rust-openssl-fab6ea4727dd70c36989f21d41ef21793eaa4006.zip |
Conditionally compile PEM functions for CMS
Apparently libressl does not quite support all CMS functions (well, at
least the bindings for CMS are currently compile-time guarded), so CI
checks inside the systest fail during the verification on libressl.
This is an attempt to fix it.
-rw-r--r-- | openssl-sys/src/pem.rs | 2 | ||||
-rw-r--r-- | openssl/src/cms.rs | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/openssl-sys/src/pem.rs b/openssl-sys/src/pem.rs index 6bc2eca3..64703377 100644 --- a/openssl-sys/src/pem.rs +++ b/openssl-sys/src/pem.rs @@ -147,12 +147,14 @@ extern "C" { pub fn PEM_write_bio_PKCS7(bp: *mut BIO, x: *mut PKCS7) -> c_int; + #[cfg(ossl101)] pub fn PEM_read_bio_CMS( bio: *mut BIO, out: *mut *mut CMS_ContentInfo, callback: pem_password_cb, user_data: *mut c_void, ) -> *mut CMS_ContentInfo; + #[cfg(ossl101)] pub fn PEM_write_bio_CMS(bio: *mut BIO, cms: *const CMS_ContentInfo) -> c_int; } diff --git a/openssl/src/cms.rs b/openssl/src/cms.rs index fb5d627b..21af2a80 100644 --- a/openssl/src/cms.rs +++ b/openssl/src/cms.rs @@ -248,11 +248,10 @@ mod test { let encrypt = CmsContentInfo::encrypt(&cert_stack, &input.as_bytes(), Cipher::des_ede3_cbc(), CMSOptions::empty()) .expect("failed create encrypted cms"); - let encrypted_der = encrypt.to_der().expect("failed to create der from cms"); - let encrypted_pem = encrypt.to_pem().expect("failed to create pem from cms"); // decrypt cms message using private key cert (DER) { + let encrypted_der = encrypt.to_der().expect("failed to create der from cms"); let decrypt = CmsContentInfo::from_der(&encrypted_der).expect("failed read cms from der"); let decrypt = decrypt.decrypt(&priv_cert.pkey, &priv_cert.cert).expect("failed to decrypt cms"); let decrypt = String::from_utf8(decrypt).expect("failed to create string from cms content"); @@ -261,6 +260,7 @@ mod test { // decrypt cms message using private key cert (PEM) { + let encrypted_pem = encrypt.to_pem().expect("failed to create pem from cms"); let decrypt = CmsContentInfo::from_pem(&encrypted_pem).expect("failed read cms from pem"); let decrypt = decrypt.decrypt(&priv_cert.pkey, &priv_cert.cert).expect("failed to decrypt cms"); let decrypt = String::from_utf8(decrypt).expect("failed to create string from cms content"); |