Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

wvx509.h

00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
00004  *
00005  * X.509 certificate management classes.
00006  */ 
00007 #ifndef __WVX509_H
00008 #define __WVX509_H
00009 
00010 #include "wvlog.h"
00011 #include "wverror.h"
00012 
00013 // Structures to make the compiler happy so we don't have to include x509v3.h ;)
00014 struct x509_st;
00015 typedef struct x509_st X509;
00016 struct ssl_ctx_st;
00017 typedef struct ssl_ctx_st SSL_CTX;
00018 struct X509_crl_st;
00019 typedef struct X509_crl_st X509_CRL;
00020 class WvRSAKey;
00021 
00022 // workaround for the fact that OpenSSL initialization stuff must be called
00023 // only once.
00024 void wvssl_init();
00025 void wvssl_free();
00026 WvString wvssl_errstr();
00027 
00028 
00033 class WvX509Mgr : public WvError
00034 {
00035 public:
00044     enum DumpMode { CertPEM = 0, RsaPEM, RsaPubPEM, RsaRaw };
00045 
00054     WvX509Mgr(X509 *_cert = NULL);
00055 
00060     WvX509Mgr(WvStringParm hexcert, WvStringParm hexrsa);
00061 
00078     WvX509Mgr(WvStringParm _dname, WvRSAKey *_rsa);
00079     
00086     WvX509Mgr(WvStringParm _dname, int bits);
00087 
00088 private:
00093     WvX509Mgr(const WvX509Mgr &mgr);
00094 
00095 public:
00097     virtual ~WvX509Mgr();
00098     
00104     bool bind_ssl(SSL_CTX *ctx);
00105  
00109     const WvRSAKey &get_rsa();
00110     
00115     void create_selfsigned(bool is_ca = false);
00116 
00129     WvString certreq();
00130     
00131 
00137     WvString signcert(WvStringParm pkcs10req);
00138     
00139     
00145     bool test();
00146 
00152     void unhexify(WvStringParm encodedcert);
00153     
00162     WvString hexify();
00163 
00171     bool validate(WvX509Mgr *cacert = NULL, X509_CRL *crl = NULL);
00172 
00178     bool signedbyCAindir(WvStringParm certdir);
00179    
00184     bool signedbyCAinfile(WvStringParm certfile);
00185 
00190     bool signedbyCA(WvX509Mgr *cacert);
00191 
00196     WvString sign(WvBuf &data);
00197     WvString sign(WvStringParm data);
00198 
00205     bool verify(WvBuf &original, WvStringParm signature);
00206     bool verify(WvStringParm original, WvStringParm signature);
00207     
00211     WvString encode(const DumpMode mode);
00212 
00219     void decode(const DumpMode mode, WvStringParm PemEncoded);
00220 
00229     void write_p12(WvStringParm filename);
00230     
00235     void read_p12(WvStringParm filename);
00236 
00238     void setPkcs12Password(WvStringParm passwd)
00239         { pkcs12pass = passwd; }
00240 
00245     WvString get_issuer();
00246 
00250     WvString get_subject();
00251 
00255     WvString get_serial();
00256 
00261     WvString get_crl_dp();
00262 
00267     WvString get_cp_oid();
00268 
00273     WvString get_altsubject();
00274 
00278     virtual bool isok() const;
00279 
00280     virtual WvString errstr() const;
00281 
00282     virtual int geterr() const;
00283 
00284 private:
00286     X509     *cert;
00287 
00293     WvRSAKey *rsa;
00294     
00296     WvString dname;
00297 
00298     WvLog debug;
00299     
00304     WvString pkcs12pass;
00305 
00310     WvString get_extension(int nid);
00311 
00315     void filldname();
00316 
00321     WvRSAKey *fillRSAPubKey();
00322 };
00323 
00324 #endif // __WVX509_H

Generated on Fri May 20 11:17:46 2005 for WvStreams by  doxygen 1.4.2