diff options
| author | Benjamin Fry <[email protected]> | 2017-02-20 14:48:49 -0800 |
|---|---|---|
| committer | Benjamin Fry <[email protected]> | 2017-02-20 14:48:49 -0800 |
| commit | 9b24698aeee96e2089b74656e33a401f8f9fb5e1 (patch) | |
| tree | b9864383e22a61d10b2cae4bbf1dc04e21c9f5c2 /openssl/src | |
| parent | Merge pull request #584 from sfackler/more-error-info (diff) | |
| download | rust-openssl-9b24698aeee96e2089b74656e33a401f8f9fb5e1.tar.xz rust-openssl-9b24698aeee96e2089b74656e33a401f8f9fb5e1.zip | |
some helpful documentation and example.
Diffstat (limited to 'openssl/src')
| -rw-r--r-- | openssl/src/x509/mod.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/openssl/src/x509/mod.rs b/openssl/src/x509/mod.rs index 4df05ad0..1a5f164b 100644 --- a/openssl/src/x509/mod.rs +++ b/openssl/src/x509/mod.rs @@ -326,6 +326,23 @@ impl X509Builder { } /// Sets the subject name of the certificate. + /// + /// When building certificates, the `C`, `ST`, and `O` options are required for the certificate to be a valid certificate in OpenSSL. + /// The `CN` field is used for the common name, such as a DNS name. + /// + /// ``` + /// use openssl::x509::{X509, X509NameBuilder}; + /// + /// let mut x509_name = openssl::x509::X509NameBuilder::new().unwrap(); + /// x509_name.append_entry_by_text("C", "US").unwrap(); + /// x509_name.append_entry_by_text("ST", "CA").unwrap(); + /// x509_name.append_entry_by_text("O", "Some organization").unwrap(); + /// x509_name.append_entry_by_text("CN", "www.example.com").unwrap(); + /// let x509_name = x509_name.build(); + /// + /// let mut x509 = openssl::x509::X509::builder().unwrap(); + /// x509.set_subject_name(&x509_name).unwrap(); + /// ``` pub fn set_subject_name(&mut self, subject_name: &X509NameRef) -> Result<(), ErrorStack> { unsafe { cvt(ffi::X509_set_subject_name(self.0.as_ptr(), subject_name.as_ptr())).map(|_| ()) |