diff options
| author | Steven Fackler <[email protected]> | 2016-11-13 15:12:50 +0000 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2016-11-13 15:12:50 +0000 |
| commit | 2a8923c05073d533175ed94d2931a3a79273a684 (patch) | |
| tree | abeccb6913cf808346a6e8ae9a2f04301db2255f /openssl/src/macros.rs | |
| parent | Some serialization support for EcKey (diff) | |
| download | rust-openssl-2a8923c05073d533175ed94d2931a3a79273a684.tar.xz rust-openssl-2a8923c05073d533175ed94d2931a3a79273a684.zip | |
Macro-implement private_key_to_pem
Diffstat (limited to 'openssl/src/macros.rs')
| -rw-r--r-- | openssl/src/macros.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/openssl/src/macros.rs b/openssl/src/macros.rs index 0db3401c..b225f322 100644 --- a/openssl/src/macros.rs +++ b/openssl/src/macros.rs @@ -75,3 +75,22 @@ macro_rules! private_key_from_pem { } } } + +macro_rules! private_key_to_pem { + ($f:path) => { + /// Serializes the private key to PEM. + pub fn private_key_to_pem(&self) -> Result<Vec<u8>, ::error::ErrorStack> { + unsafe { + let bio = try!(MemBio::new()); + try!(cvt($f(bio.as_ptr(), + self.as_ptr(), + ptr::null(), + ptr::null_mut(), + -1, + None, + ptr::null_mut()))); + Ok(bio.get_buf().to_owned()) + } + } + } +} |