From 64106c4d3d4ddba8c7bc2af75376e6d3d3d75601 Mon Sep 17 00:00:00 2001 From: Date: Mon, 29 Jun 2015 20:16:15 +0000 Subject: Update documentation --- openssl/x509/struct.X509Generator.html | 160 +++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 openssl/x509/struct.X509Generator.html (limited to 'openssl/x509/struct.X509Generator.html') diff --git a/openssl/x509/struct.X509Generator.html b/openssl/x509/struct.X509Generator.html new file mode 100644 index 0000000..c60f452 --- /dev/null +++ b/openssl/x509/struct.X509Generator.html @@ -0,0 +1,160 @@ + + + + + + + + + + openssl::x509::X509Generator - Rust + + + + + + + + + + + + + + + +
+

Struct openssl::x509::X509Generator + + [] + + [src]

+
pub struct X509Generator {
+    // some fields omitted
+}

Generator of private key/certificate pairs

+ +

Example

+use std::fs;
+use std::fs::File;
+use std::io::prelude::*;
+use std::path::Path;
+
+use openssl::crypto::hash::Type;
+use openssl::x509::{KeyUsage, X509Generator};
+
+let gen = X509Generator::new()
+       .set_bitlength(2048)
+       .set_valid_period(365*2)
+       .set_CN("SuperMegaCorp Inc.")
+       .set_sign_hash(Type::SHA256)
+       .set_usage(&[KeyUsage::DigitalSignature]);
+
+let (cert, pkey) = gen.generate().unwrap();
+
+let cert_path = "doc_cert.pem";
+let mut file = File::create(cert_path).unwrap();
+assert!(cert.write_pem(&mut file).is_ok());
+
+let pkey_path = "doc_key.pem";
+let mut file = File::create(pkey_path).unwrap();
+assert!(pkey.write_pem(&mut file).is_ok());
+
+

Methods

impl X509Generator

fn new() -> X509Generator

+

Creates a new generator with the following defaults:

+ +

bit length: 1024

+ +

validity period: 365 days

+ +

CN: "rust-openssl"

+ +

hash: SHA1

+

fn set_bitlength(self, bits: u32) -> X509Generator

+

Sets desired bit length

+

fn set_valid_period(self, days: u32) -> X509Generator

+

Sets certificate validity period in days since today

+

fn set_CN(self, CN: &str) -> X509Generator

+

Sets Common Name of certificate

+

fn set_usage(self, purposes: &[KeyUsage]) -> X509Generator

+

Sets what for certificate could be used

+

fn set_ext_usage(self, purposes: &[ExtKeyUsage]) -> X509Generator

+

Sets allowed extended usage of certificate

+

fn set_sign_hash(self, hash_type: Type) -> X509Generator

+

fn generate<'a>(&self) -> Result<(X509<'a>, PKey), SslError>

+

Generates a private key and a self-signed certificate and returns them

+

fn sign<'a>(&self, p_key: &PKey) -> Result<X509<'a>, SslError>

+

Sets the certificate public-key, then self-sign and return it +Note: That the bit-length of the private key is used (set_bitlength is ignored)

+

fn request(&self, p_key: &PKey) -> Result<X509Req, SslError>

+

Obtain a certificate signing request (CSR)

+
+ + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3