Module openssl::x509
[−]
[src]
The standard defining the format of public key certificates.
An X509
certificate binds an identity to a public key, and is either
signed by a certificate authority (CA) or self-signed. An entity that gets
a hold of a certificate can both verify your identity (via a CA) and encrypt
data with the included public key. X509
certificates are used in many
Internet protocols, including SSL/TLS, which is the basis for HTTPS,
the secure protocol for browsing the web.
Example
Build an X509
certificate and use a generated RSA key to sign it.
extern crate openssl; use openssl::x509::{X509, X509Name}; use openssl::pkey::PKey; use openssl::hash::MessageDigest; use openssl::rsa::Rsa; use openssl::nid::Nid; fn main() { let rsa = Rsa::generate(2048).unwrap(); let pkey = PKey::from_rsa(rsa).unwrap(); let mut name = X509Name::builder().unwrap(); name.append_entry_by_nid(Nid::COMMONNAME, "foobar.com").unwrap(); let name = name.build(); let mut builder = X509::builder().unwrap(); builder.set_version(2).unwrap(); builder.set_subject_name(&name).unwrap(); builder.set_issuer_name(&name).unwrap(); builder.set_pubkey(&pkey).unwrap(); builder.sign(&pkey, MessageDigest::sha256()).unwrap(); let certificate: X509 = builder.build(); }
Modules
extension |
Add extensions to an |
store |
Describe a context in which to verify an |
verify |
X509 certificate verification |
Structs
GeneralName |
An |
GeneralNameRef |
Reference to |
X509 |
An |
X509Algorithm |
An |
X509AlgorithmRef |
Reference to |
X509Builder |
A builder used to construct an |
X509Extension |
Permit additional fields to be added to an |
X509ExtensionRef |
Reference to |
X509Name |
The names of an |
X509NameBuilder |
A builder used to construct an |
X509NameEntries |
A type to destructure and examine an |
X509NameEntry |
A name entry associated with a |
X509NameEntryRef |
Reference to |
X509NameRef |
Reference to |
X509Ref |
Reference to |
X509Req |
An |
X509ReqBuilder |
A builder used to construct an |
X509ReqRef |
Reference to |
X509StoreContext |
An |
X509StoreContextRef |
Reference to |
X509VerifyResult |
The result of peer certificate verification. |
X509v3Context |
A context object required to construct certain |