00001 #ifndef __SSL_CTX_H__
00002 #define __SSL_CTX_H__
00003
00004 #include <openssl/rsa.h>
00005 #include <openssl/crypto.h>
00006 #include <openssl/x509.h>
00007 #include <openssl/pem.h>
00008 #include <openssl/ssl.h>
00009 #include <openssl/err.h>
00010 #include <openssl/rand.h>
00011 #include <string>
00012
00013 class SslCtx
00014 {
00015 public:
00016 SslCtx();
00017 ~SslCtx();
00018
00019 SSL_CTX* getSslCtx();
00020
00021 long setOptions(long);
00022 long getOptions();
00023 void setPrivateKeyPassword(string password);
00024 bool setCertificateFile(string certificateFile);
00025 bool setPrivateKeyFile(string privateKeyFile);
00026 bool setPrivateKeyFile(string privateKeyFile, string privateKeyPassword);
00027 bool setCertificateAuthorityFile(string caFile, string caPath);
00028
00029 private:
00030 long setDefaultOptions();
00031
00032 static int verify_callback(int ok, X509_STORE_CTX *ctx);
00033
00034 static int getPrivateKeyPasswordCallback(char *buf, int len, int rwflag, void* user_data);
00035
00036
00038 SSL_CTX *m_sslCtx;
00039
00041 std::string m_privateKeyPassword;
00042 };
00043
00044 #endif