From 9b24698aeee96e2089b74656e33a401f8f9fb5e1 Mon Sep 17 00:00:00 2001 From: Benjamin Fry Date: Mon, 20 Feb 2017 14:48:49 -0800 Subject: [PATCH 1/2] some helpful documentation and example. --- openssl/src/x509/mod.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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(|_| ()) From b4318960577f319e095f8a4f83bdf771f4b46309 Mon Sep 17 00:00:00 2001 From: Benjamin Fry Date: Wed, 22 Feb 2017 22:05:39 -0800 Subject: [PATCH 2/2] mention the common fields --- openssl/src/x509/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openssl/src/x509/mod.rs b/openssl/src/x509/mod.rs index 1a5f164b..bab1d711 100644 --- a/openssl/src/x509/mod.rs +++ b/openssl/src/x509/mod.rs @@ -327,7 +327,7 @@ 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. + /// When building certificates, the `C`, `ST`, and `O` options are common when using the openssl command line tools. /// The `CN` field is used for the common name, such as a DNS name. /// /// ```