WvStreams
wvx509mgr.h
1 /* -*- Mode: C++ -*-
2  *
3  * X.509 certificate management class: This class builds upon the
4  * functionality provided by the WvX509 class, adding operations that are
5  * made possible with the addition of a private key (e.g. signing certificates
6  * and CRLs).
7  */
8 #ifndef __WVX509MGR_H
9 #define __WVX509MGR_H
10 
11 #include "wvx509.h"
12 #include "wvcrl.h"
13 
14 class WvX509Mgr : public WvX509
15 {
16  public:
21  WvX509Mgr();
22 
40  WvX509Mgr(WvStringParm _dname, WvRSAKey *_rsa, bool ca = false);
41 
49  WvX509Mgr(WvStringParm _dname, int bits, bool ca=false);
50 
54  WvX509Mgr(const WvX509Mgr &mgr);
55 
56  protected:
65  void create_selfissued(WvStringParm dname, bool is_ca = false);
66 
67 public:
69  virtual ~WvX509Mgr();
70 
75  virtual bool isok() const;
76 
80  virtual WvString errstr() const;
81 
85  bool operator! () const;
86 
90  WvRSAKey *get_rsa() { return rsa; }
91  void set_rsa(WvRSAKey *_rsa) { WVDELETE(rsa); rsa = new WvRSAKey(*_rsa); }
92 
98  bool bind_ssl(SSL_CTX *ctx);
99 
105  WvString signreq(WvStringParm pkcs10req) const;
106 
110  bool signcert(WvX509 &unsignedcert) const;
111 
117  bool signcrl(WvCRL &unsignedcrl) const;
118 
124  bool test() const;
125 
130  WvString sign(WvBuf &data) const;
131  WvString sign(WvStringParm data) const;
132 
136  virtual WvString encode(const WvX509::DumpMode mode) const;
137  virtual WvString encode(const WvRSAKey::DumpMode mode) const;
138  virtual void encode(const WvX509::DumpMode mode, WvBuf &buf) const;
139  virtual void encode(const WvRSAKey::DumpMode mode, WvBuf &buf) const;
140 
147  virtual void decode(const WvX509::DumpMode mode, WvStringParm encoded);
148  virtual void decode(const WvRSAKey::DumpMode mode, WvStringParm encoded);
149  virtual void decode(const WvX509::DumpMode mode, WvBuf &encoded);
150  virtual void decode(const WvRSAKey::DumpMode mode, WvBuf &encoded);
151 
157  bool write_p12(WvStringParm _fname, WvStringParm _pkcs12pass) const;
158 
164  void read_p12(WvStringParm _fname, WvStringParm _pkcs12pass);
165 
166  private:
172  mutable WvRSAKey *rsa;
173 
174  mutable WvLog debug;
175 };
176 #endif
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
Definition: wvstring.h:93
void read_p12(WvStringParm _fname, WvStringParm _pkcs12pass)
And this reads from the file specified in filename using the password "_pkcs12pass", and fills the RSA and cert members with the decoded information.
Definition: wvx509mgr.cc:556
virtual ~WvX509Mgr()
Destructor.
Definition: wvx509mgr.cc:165
WvString sign(WvBuf &data) const
Sign the contents of data and return the signature as a BASE64 string.
Definition: wvx509mgr.cc:453
virtual void decode(const WvX509::DumpMode mode, WvStringParm encoded)
Load the information from the format requested by mode into the class - this overwrites the certifica...
Definition: wvx509mgr.cc:659
virtual WvString encode(const WvX509::DumpMode mode) const
Encodes the information requested by mode into a buffer.
Definition: wvx509mgr.cc:628
bool signcrl(WvCRL &unsignedcrl) const
Sign the CRL with the rsa key associated with this class.
Definition: wvx509mgr.cc:391
X509 Class to handle certificates and their related functions.
Definition: wvx509.h:41
virtual WvString errstr() const
Says what the error is, if isok() is not true.
Definition: wvx509mgr.cc:184
bool signcert(WvX509 &unsignedcert) const
Sign the certificate with the rsa key associated with this class.
Definition: wvx509mgr.cc:344
bool test() const
Test to make sure that a certificate and a keypair go together.
Definition: wvx509mgr.cc:217
WvRSAKey * get_rsa()
Allow us access to the RSA member.
Definition: wvx509mgr.h:90
WvX509Mgr()
Constructor to create a blank certificate + keypair (useful if, for example, you were going to load t...
Definition: wvx509mgr.cc:35
Specialization of WvBufBase for unsigned char type buffers intended for use with raw memory buffers...
Definition: wvbuf.h:22
bool write_p12(WvStringParm _fname, WvStringParm _pkcs12pass) const
This writes the certificate and RSA keys in PKCS12 format to the file specified by filename...
Definition: wvx509mgr.cc:491
DumpMode
Type for the encode() and decode() methods.
Definition: wvx509.h:56
WvString signreq(WvStringParm pkcs10req) const
Take the PKCS#10 request in the string pkcs10req, sign it with the private key in rsa...
Definition: wvx509mgr.cc:267
bool operator!() const
The not operator returns true if !isok()
Definition: wvx509mgr.cc:178
bool bind_ssl(SSL_CTX *ctx)
Avoid a lot of ugliness by having it so that we are binding to the SSL context, and not the other way...
Definition: wvx509mgr.cc:200
void create_selfissued(WvStringParm dname, bool is_ca=false)
Given the Distinguished Name dname and an already generated keypair in rsa, return a Self Signed Cert...
Definition: wvx509mgr.cc:89
An RSA public key or public/private key pair that can be used for encryption.
Definition: wvrsa.h:26
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:329
virtual bool isok() const
Says if this certificate+key pair is good for use.
Definition: wvx509mgr.cc:172
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's...
Definition: wvlog.h:56
CRL Class to handle certificate revocation lists and their related functions.
Definition: wvcrl.h:28
DumpMode
Type for the encode() and decode() methods.
Definition: wvrsa.h:36