conexus logo

context.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2008 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This file is part of the conexus library.                             *
00006  *                                                                         *
00007  *   The conexus library is free software; you can redistribute it and/or  *
00008  *   modify it under the terms of the GNU General Public License           *
00009  *   version 3 as published by the Free Software Foundation.               *
00010  *                                                                         *
00011  *   The conexus library is distributed in the hope that it will be        *
00012  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty   *
00013  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   *
00014  *   General Public License for more details.                              *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU General Public License     *
00017  *   along with this software. If not see <http://www.gnu.org/licenses/>.  *
00018  ***************************************************************************/
00019 #ifndef CONEXUS_SSLCONTEXT_H
00020 #define CONEXUS_SSLCONTEXT_H
00021 
00022 #include <string>
00023 
00024 #include <openssl/ssl.h>
00025 
00026 #include <sigc++/sigc++.h>
00027 
00028 #include <conexus/pointer.h>
00029 #include <conexus-ssl/enums.h>
00030 
00031 namespace Conexus
00032 {
00033 
00034   namespace SSL
00035   {
00036 
00040     class Context
00041     {
00042       protected:
00043         Context ( Method m );
00044 
00045       public:
00046         typedef ConexusPointer<Context> pointer;
00047 
00048         static pointer create ( Method m=SSLV23 );
00049 
00050         virtual ~Context();
00051 
00052         Method method();
00053 
00060         bool use_certificate ( X509 *x );
00061 
00066         bool use_certificate_asn1 ( int len, unsigned char *d );
00067 
00074         bool use_certificate_file ( const std::string& file, FileType type );
00075 
00084         bool use_certificate_chain_file ( const std::string& file );
00085 
00094         bool use_private_key ( EVP_PKEY *pkey );
00095 
00099         bool use_private_key_asn1 ( int pk, unsigned char *d, long len );
00100 
00107         bool use_private_key_file ( const std::string& file, FileType type );
00108 
00117         bool use_rsa_private_key ( RSA *rsa );
00118 
00122         bool use_rsa_private_key_asn1 ( unsigned char *d, long len );
00123 
00130         bool use_rsa_private_key_file ( const std::string& file, FileType type );
00131 
00141         bool check_private_key() const;
00142 
00152         typedef sigc::slot<void,std::string&,EncDecFlag> PasswordSlot;
00153 
00158         void set_default_password_slot ( PasswordSlot slot=PasswordSlot() );
00159 
00161         bool load_verify_locations ( const std::string& ca_file, const std::string& ca_path=std::string() );
00162 
00167         void set_verify_depth ( int depth );
00168 
00173         void set_read_ahead( bool set=true );
00174 
00176         SSL_CTX* cobj();
00177 
00178       protected:
00180         Method m_method;
00181 
00183         SSL_CTX* m_cobj;
00184 
00186         PasswordSlot m_default_password_slot;
00187 
00189         static int passwd_cb_proxy ( char* buf, int size, int rwflag, void* userdata );
00190 
00191     };
00192 
00193   }
00194 
00195 }
00196 
00197 #endif

Generated on Wed Jul 8 15:50:07 2009 for conexus by doxygen 1.5.8