X509_Context::Identity Struct Reference
Public Member Functions | |
| EVENTSVC_DLL | Identity (Config &) |
| EVENTSVC_DLL | Identity (PKCS12 *p12, const char *pphr) |
Data Fields | |
| X509_IDENTITY * | identity |
| X509_CERT_CTX * | cert_ctx |
Detailed Description
Definition at line 47 of file X509Context.h.
Constructor & Destructor Documentation
◆ Identity() [1/2]
| X509_Context::Identity::Identity | ( | Config & | confobj | ) |
Definition at line 63 of file X509Context.C.
64 {
65 const std::string pkcs12_file(confobj.ident_file);
66 const std::string pphr_file(confobj.ident_pphr_file);
67 if (pkcs12_file.empty() || pphr_file.empty())
68 throw std::invalid_argument("no private key info");
69
70 identity = x509_create_identity_from_file(pkcs12_file.c_str(),
71 pphr_file.c_str(), 1);
72 if (!identity)
73 throw std::runtime_error("unable to create identity");
74 cert_ctx = x509_create_cert_ctx();
75 if (!cert_ctx)
76 throw std::runtime_error("unable to create cert_ctx");
77 x509_cert_ctx_add_identity(cert_ctx, identity);
78
79 for (std::list<std::string>::const_iterator
80 i = confobj.trust_anchors.begin();
81 i != confobj.trust_anchors.end(); ++i) {
82 const std::string& name = *i;
83 X509 *ta = x509_read_cert(name.c_str());
84 if (ta)
85 x509_cert_ctx_add_cert(cert_ctx, ta, 1);
86 X509_free(ta);
87 }
88
89 for (std::list<std::string>::const_iterator i = confobj.certs.begin();
90 i != confobj.certs.end(); ++i) {
91 const std::string& name = *i;
92 X509 *cert = x509_read_cert(name.c_str());
93 if (cert)
94 x509_cert_ctx_add_cert(cert_ctx, cert, 0);
95 X509_free(cert);
96 }
97
98 x509_cert_ctx_set_ldap(cert_ctx, confobj.ldap_host.empty() ?
99 0:confobj.ldap_host.c_str(), confobj.ldap_port);
100 x509_cert_ctx_check_revocation(cert_ctx, confobj.check_revocation);
101
102 X509* OCSPresponder = 0;
103 if (!confobj.OCSPresponder.empty()) {
104 OCSPresponder = x509_read_cert(confobj.OCSPresponder.c_str());
105 }
106 x509_cert_ctx_set_ocsp(cert_ctx, confobj.OCSPuri.c_str(), OCSPresponder,
107 confobj.OCSPnonce, 0, 0);
108
109 x509_cert_ctx_set_lookup_flags(cert_ctx, confobj.lookup_flags);
110 }
◆ Identity() [2/2]
| X509_Context::Identity::Identity | ( | PKCS12 * | p12, |
| const char * | pphr | ||
| ) |
Definition at line 112 of file X509Context.C.
113 {
114 identity = x509_create_identity_from_pkcs12(p12, passphrase);
115
116 if (!identity)
117 throw std::runtime_error("unable to create identity");
118 cert_ctx = x509_create_cert_ctx();
119 if (!cert_ctx)
120 throw std::runtime_error("unable to create cert_ctx");
121 x509_cert_ctx_add_identity(cert_ctx, identity);
122 }
◆ ~Identity()
|
inline |
Definition at line 53 of file X509Context.h.
53 {
54 x509_destroy_identity(&identity);
55 x509_destroy_cert_ctx(&cert_ctx);
56 }
Field Documentation
◆ identity
| X509_IDENTITY* X509_Context::Identity::identity |
Definition at line 48 of file X509Context.h.
◆ cert_ctx
| X509_CERT_CTX* X509_Context::Identity::cert_ctx |
Definition at line 49 of file X509Context.h.
The documentation for this struct was generated from the following files: