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");