aboutsummaryrefslogtreecommitdiff
path: root/openssl/src
diff options
context:
space:
mode:
authorManuel Schölling <[email protected]>2015-03-21 17:57:02 +0100
committerManuel Schölling <[email protected]>2015-03-21 18:02:29 +0100
commit6373b9692438d1941f1f52abf7adcb5aa96e14d3 (patch)
tree45fd5f88eb6ffc9209347f59697ee03bbd3fad45 /openssl/src
parentFix warnings and build issues (diff)
downloadrust-openssl-6373b9692438d1941f1f52abf7adcb5aa96e14d3.tar.xz
rust-openssl-6373b9692438d1941f1f52abf7adcb5aa96e14d3.zip
Add X509Generator::sign()
Diffstat (limited to 'openssl/src')
-rw-r--r--openssl/src/x509/mod.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/openssl/src/x509/mod.rs b/openssl/src/x509/mod.rs
index 33ed1fa5..b031a239 100644
--- a/openssl/src/x509/mod.rs
+++ b/openssl/src/x509/mod.rs
@@ -298,6 +298,15 @@ impl X509Generator {
let mut p_key = PKey::new();
p_key.gen(self.bits as usize);
+ let x509 = try!(self.sign(&p_key));
+ Ok((x509, p_key))
+ }
+
+ /// Signs certificate with a private key and returns it
+ /// Note: That the bit-length of the private key is used (set_bitlength is ignored)
+ pub fn sign<'a>(&self, p_key: &PKey) -> Result<X509<'a>, SslError> {
+ ffi::init();
+
unsafe {
let x509 = ffi::X509_new();
try_ssl_null!(x509);
@@ -338,7 +347,7 @@ impl X509Generator {
let hash_fn = self.hash_type.evp_md();
try_ssl!(ffi::X509_sign(x509.handle, p_key.get_handle(), hash_fn));
- Ok((x509, p_key))
+ Ok(x509)
}
}
}