WvStreams
debian/libwvstreams-dev/usr/include/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
14class 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
67public:
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
CRL Class to handle certificate revocation lists and their related functions.
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's.
An RSA public key or public/private key pair that can be used for encryption.
DumpMode
Type for the encode() and decode() methods.
WvString is an implementation of a simple and efficient printable-string class.
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:664
WvRSAKey * get_rsa()
Allow us access to the RSA member.
virtual WvString errstr() const
Says what the error is, if isok() is not true.
Definition wvx509mgr.cc:184
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 read_p12(WvStringParm _fname, WvStringParm _pkcs12pass)
And this reads from the file specified in filename using the password "_pkcs12pass",...
Definition wvx509mgr.cc:561
bool signcrl(WvCRL &unsignedcrl) const
Sign the CRL with the rsa key associated with this class.
Definition wvx509mgr.cc:393
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:496
WvX509Mgr()
Constructor to create a blank certificate + keypair (useful if, for example, you were going to load t...
Definition wvx509mgr.cc:35
WvString sign(WvBuf &data) const
Sign the contents of data and return the signature as a BASE64 string.
Definition wvx509mgr.cc:457
virtual WvString encode(const WvX509::DumpMode mode) const
Encodes the information requested by mode into a buffer.
Definition wvx509mgr.cc:633
bool test() const
Test to make sure that a certificate and a keypair go together.
Definition wvx509mgr.cc:217
bool signcert(WvX509 &unsignedcert) const
Sign the certificate with the rsa key associated with this class.
Definition wvx509mgr.cc:344
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
virtual ~WvX509Mgr()
Destructor.
Definition wvx509mgr.cc:165
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
virtual bool isok() const
Says if this certificate+key pair is good for use.
Definition wvx509mgr.cc:172
X509 Class to handle certificates and their related functions.
DumpMode
Type for the encode() and decode() methods.