Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Public Attributes | List of all members
Botan::X509_Cert_Options Class Reference

`#include <x509self.h>`

## Public Member Functions
void | add_constraints (Key_Constraints constr)
void | add_ex_constraint (const OID &oid)
void | add_ex_constraint (const std::string &name)
void | CA_key (size_t limit=1)
void | not_after (const std::string &time)
void | not_before (const std::string &time)
| X509_Cert_Options (const std::string &opts="", uint32_t expire_time=365 *24 *60 *60)

## Public Attributes
std::string | challenge
std::string | common_name
Key_Constraints | constraints
std::string | country
std::string | dns
std::string | email
X509_Time | end
std::vector< OID > | ex_constraints
Extensions | extensions
std::string | ip
bool | is_CA
std::string | locality
std::string | org_unit
std::string | organization
size_t | path_limit
std::string | serial_number
X509_Time | start
std::string | state
std::string | uri
std::string | xmpp

## Detailed Description

Options for X.509 certificates.

Definition at line 21 of file x509self.h.

## Constructor & Destructor Documentation

Botan::X509_Cert_Options::X509_Cert_Options | ( | const std::string & | opts = `""`,
|  | uint32_t | expire_time = `365 * 24 * 60 * 60`
| ) |  |

Construct a new options object

Parameters

  opts | define the common name of this object. An example for this parameter would be "common_name/country/organization/organizational_unit".
  expire_time | the expiration time (from the current clock in seconds)

Definition at line 67 of file x509opt.cpp.

References common_name, constraints, country, end, is_CA, Botan::NO_CONSTRAINTS, org_unit, organization, path_limit, Botan::split_on(), and start.

69 {
70 is_CA = false;
71 path_limit = 0;
72 constraints = NO_CONSTRAINTS;
73
74 auto now = std::chrono::system_clock::now();
75
76 start = X509_Time(now);
77 end = X509_Time(now + std::chrono::seconds(expiration_time));
78
79 if(initial_opts.empty())
80 return;
81
82 std::vector<std::string> parsed = split_on(initial_opts, '/');
83
84 if(parsed.size() > 4)
85 throw Invalid_Argument("X.509 cert options: Too many names: "
86 + initial_opts);
87
88 if(parsed.size() >= 1) common_name = parsed[0];
89 if(parsed.size() >= 2) country = parsed[1];
90 if(parsed.size() >= 3) organization = parsed[2];
91 if(parsed.size() == 4) org_unit = parsed[3];
92 }
Botan::X509_Cert_Options::org_unit
std::string org_unit
Definition: x509self.h:42
Botan::X509_Cert_Options::country
std::string country
Definition: x509self.h:32
Botan::split_on
std::vector< std::string > split_on(const std::string &str, char delim)
Definition: parsing.cpp:138
Botan::X509_Cert_Options::path_limit
size_t path_limit
Definition: x509self.h:106
Botan::X509_Cert_Options::common_name
std::string common_name
Definition: x509self.h:27
Botan::NO_CONSTRAINTS
Definition: key_constraint.h:22
Botan::X509_Cert_Options::is_CA
bool is_CA
Definition: x509self.h:101
Botan::X509_Cert_Options::constraints
Key_Constraints constraints
Definition: x509self.h:111
Botan::X509_Cert_Options::end
X509_Time end
Definition: x509self.h:96
Botan::X509_Cert_Options::start
X509_Time start
Definition: x509self.h:92
Botan::X509_Cert_Options::organization
std::string organization
Definition: x509self.h:37

## Member Function Documentation

void Botan::X509_Cert_Options::add_constraints | ( | Key_Constraints | constr | ) |

Add the key constraints of the KeyUsage extension.

Parameters

  constr | the constraints to set

Definition at line 34 of file x509opt.cpp.

References constraints.

35 {
36 constraints = usage;
37 }
Botan::X509_Cert_Options::constraints
Key_Constraints constraints
Definition: x509self.h:111

void Botan::X509_Cert_Options::add_ex_constraint | ( | const OID & | oid | ) |

Add constraints to the ExtendedKeyUsage extension.

Parameters

  oid | the oid to add

Definition at line 42 of file x509opt.cpp.

References ex_constraints.

43 {
44 ex_constraints.push_back(oid);
45 }
Botan::X509_Cert_Options::ex_constraints
std::vector< OID > ex_constraints
Definition: x509self.h:116

void Botan::X509_Cert_Options::add_ex_constraint | ( | const std::string & | name | ) |

Add constraints to the ExtendedKeyUsage extension.

Parameters

  name | the name to look up the oid to add

Definition at line 50 of file x509opt.cpp.

References ex_constraints, and Botan::OIDS::lookup().

51 {
52 ex_constraints.push_back(OIDS::lookup(oid_str));
53 }
Botan::OIDS::lookup
std::string lookup(const OID &oid)
Definition: oids.cpp:18
Botan::X509_Cert_Options::ex_constraints
std::vector< OID > ex_constraints
Definition: x509self.h:116

void Botan::X509_Cert_Options::CA_key | ( | size_t | limit = `1` | ) |

Mark the certificate as a CA certificate and set the path limit.

Parameters

  limit | the path limit to be set in the BasicConstraints extension.

Definition at line 58 of file x509opt.cpp.

References is_CA, and path_limit.

59 {
60 is_CA = true;
61 path_limit = limit;
62 }
Botan::X509_Cert_Options::path_limit
size_t path_limit
Definition: x509self.h:106
Botan::X509_Cert_Options::is_CA
bool is_CA
Definition: x509self.h:101

void Botan::X509_Cert_Options::not_after | ( | const std::string & | time | ) |

Set the notAfter of the certificate.

Parameters

  time | the notAfter value of the certificate

Definition at line 26 of file x509opt.cpp.

References end, and Botan::UTC_OR_GENERALIZED_TIME.

27 {
28 end = X509_Time(time_string, ASN1_Tag::UTC_OR_GENERALIZED_TIME);
29 }
Botan::UTC_OR_GENERALIZED_TIME
Definition: asn1_obj.h:52
Botan::X509_Cert_Options::end
X509_Time end
Definition: x509self.h:96

void Botan::X509_Cert_Options::not_before | ( | const std::string & | time | ) |

Set the notBefore of the certificate.

Parameters

  time | the notBefore value of the certificate

Definition at line 18 of file x509opt.cpp.

References start, and Botan::UTC_OR_GENERALIZED_TIME.

19 {
20 start = X509_Time(time_string, ASN1_Tag::UTC_OR_GENERALIZED_TIME);
21 }
Botan::UTC_OR_GENERALIZED_TIME
Definition: asn1_obj.h:52
Botan::X509_Cert_Options::start
X509_Time start
Definition: x509self.h:92

## Member Data Documentation

std::string Botan::X509_Cert_Options::challenge

the subject challenge password

Definition at line 87 of file x509self.h.

Referenced by Botan::X509::create_cert_req().

std::string Botan::X509_Cert_Options::common_name

the subject common name

Definition at line 27 of file x509self.h.

Referenced by X509_Cert_Options().

Key_Constraints Botan::X509_Cert_Options::constraints

The key constraints for the subject public key

Definition at line 111 of file x509self.h.

Referenced by add_constraints(), Botan::X509::create_cert_req(), Botan::X509::create_self_signed_cert(), and X509_Cert_Options().

std::string Botan::X509_Cert_Options::country

the subject counry

Definition at line 32 of file x509self.h.

Referenced by X509_Cert_Options().

std::string Botan::X509_Cert_Options::dns

the subject DNS

Definition at line 77 of file x509self.h.

std::string Botan::X509_Cert_Options::email

the subject email adress

Definition at line 62 of file x509self.h.

X509_Time Botan::X509_Cert_Options::end

the subject notAfter

Definition at line 96 of file x509self.h.

Referenced by Botan::X509::create_self_signed_cert(), not_after(), and X509_Cert_Options().

std::vector<OID> Botan::X509_Cert_Options::ex_constraints

The key extended constraints for the subject public key

Definition at line 116 of file x509self.h.

Referenced by add_ex_constraint(), Botan::X509::create_cert_req(), and Botan::X509::create_self_signed_cert().

Extensions Botan::X509_Cert_Options::extensions

Additional X.509 extensions

Definition at line 121 of file x509self.h.

Referenced by Botan::X509::create_cert_req(), and Botan::X509::create_self_signed_cert().

std::string Botan::X509_Cert_Options::ip

the subject IPv4 address

Definition at line 72 of file x509self.h.

bool Botan::X509_Cert_Options::is_CA

Indicates whether the certificate request

Definition at line 101 of file x509self.h.

Referenced by CA_key(), Botan::X509::create_cert_req(), Botan::X509::create_self_signed_cert(), and X509_Cert_Options().

std::string Botan::X509_Cert_Options::locality

the subject locality

Definition at line 47 of file x509self.h.

std::string Botan::X509_Cert_Options::org_unit

the subject organizational unit

Definition at line 42 of file x509self.h.

Referenced by X509_Cert_Options().

std::string Botan::X509_Cert_Options::organization

the subject organization

Definition at line 37 of file x509self.h.

Referenced by X509_Cert_Options().

size_t Botan::X509_Cert_Options::path_limit

Indicates the BasicConstraints path limit

Definition at line 106 of file x509self.h.

Referenced by CA_key(), Botan::X509::create_cert_req(), Botan::X509::create_self_signed_cert(), and X509_Cert_Options().

std::string Botan::X509_Cert_Options::serial_number

the subject serial number

Definition at line 57 of file x509self.h.

X509_Time Botan::X509_Cert_Options::start

the subject notBefore

Definition at line 92 of file x509self.h.

Referenced by Botan::X509::create_self_signed_cert(), not_before(), and X509_Cert_Options().

std::string Botan::X509_Cert_Options::state

the subject state

Definition at line 52 of file x509self.h.

std::string Botan::X509_Cert_Options::uri

the subject URI

Definition at line 67 of file x509self.h.

std::string Botan::X509_Cert_Options::xmpp

the subject XMPP

Definition at line 82 of file x509self.h.

The documentation for this class was generated from the following files:

- src/lib/x509/x509self.h
- src/lib/x509/x509opt.cpp