Pkey::private_key_from_pkcs8 free p8inf

This commit is contained in:
oberien 2019-12-03 03:05:05 +01:00
parent 4b2d46c252
commit fc529b6c81
2 changed files with 7 additions and 2 deletions

View File

@ -141,6 +141,9 @@ extern "C" {
bp: *mut BIO,
x: *mut *mut PKCS8_PRIV_KEY_INFO,
) -> *mut PKCS8_PRIV_KEY_INFO;
pub fn PKCS8_PRIV_KEY_INFO_free(
p8inf: *mut PKCS8_PRIV_KEY_INFO,
);
pub fn PEM_read_bio_PKCS7(
bio: *mut BIO,

View File

@ -538,8 +538,10 @@ impl PKey<Private> {
bio.as_ptr(),
ptr::null_mut(),
))?;
cvt_p(ffi::EVP_PKCS82PKEY(p8inf))
.map(|p| PKey::from_ptr(p))
let res = cvt_p(ffi::EVP_PKCS82PKEY(p8inf))
.map(|p| PKey::from_ptr(p));
ffi::PKCS8_PRIV_KEY_INFO_free(p8inf);
res
}
}