Debian Codegraph @

src/CertificateAuthority.hpp

raw
1 #ifndef __HPP_CERTIFICATEAUTHORITY
2 #define __HPP_CERTIFICATEAUTHORITY
3
4 #include "String.hpp"
5
6 struct ca_serial {
7 ASN1_INTEGER *asn;
8 char *charhex;
9 char *filepath;
10 char *filename;
11 };
12
13 void log_ssl_errors( const char *mess, const char *site);
14
15 class CertificateAuthority
16 {
17
18 protected:
19 EVP_PKEY *_caPrivKey;
20 EVP_PKEY *_certPrivKey;
21 X509 *_caCert;
22 std::string _certPath;
23 int _certPathLen;
24 std::string _certLinks;
25 time_t _ca_start;
26 time_t _ca_end;
27 static int do_mkdir(const char *path, mode_t mode);
28 int mkpath(const char *path, mode_t mode);
29 bool addExtension(X509 *cert, int nid, char *value);
30
31 public:
32 CertificateAuthority(const char *caCert,
33 const char *caPrivKey,
34 const char *certPrivKey,
35 const char *certPath,
36 time_t &caStart,
37 time_t &caEnd);
38
39 ~CertificateAuthority();
40 X509 *generateCertificate(const char *commonname, struct ca_serial *cser, bool is_ip = false);
41 ASN1_TIME *notAfter, *notBefore;
42 bool getSerial(const char *commonname, struct ca_serial *cser);
43 bool getServerCertificate(const char *commonname, X509 **cert, struct ca_serial *cser, bool is_ip = false);
44 bool writeCertificate(const char *hostname, X509 *newCert, struct ca_serial *cser);
45 EVP_PKEY *getServerPkey();
46 bool free_ca_serial(struct ca_serial *cs);
47 String cert_start_stop_hash;
48 bool checkValidNotBefore(time_t &start);
49 bool checkValidNotAfter(time_t &end);
50 void ans1_time_to_time_t(ASN1_TIME *a_time, time_t *t_time);
51 //String ASN1TIME2String(ASN1_TIME *atime);
52 };
53
54
55 #endif //__HPP_CERTIFICATEAUTHORITY