conexus logo

ssl.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_SSLSSL_H
00020 #define CONEXUS_SSLSSL_H
00021 
00022 #include <string>
00023 
00024 #include <openssl/ssl.h>
00025 
00026 #include <conexus/pointer.h>
00027 #include <conexus/data.h>
00028 #include <conexus/except.h>
00029 #include <conexus-ssl/enums.h>
00030 #include <conexus-ssl/context.h>
00031 
00032 namespace Conexus
00033 {
00034 
00035   namespace SSL
00036   {
00037 
00041     class SSL
00042     {
00043       protected:
00044         SSL(Context::pointer context);
00045 
00046       public:
00047         typedef ConexusPointer<SSL> pointer;
00048 
00049         static pointer create(Context::pointer context = Context::pointer());
00050 
00051         ~SSL();
00052 
00053         ssize_t ssl_write( const Data data );
00054 
00055         ssize_t ssl_write( const char* data, size_t datalen );
00056 
00057         Data ssl_read( size_t s = 0 );
00058 
00059         size_t ssl_input_available();
00060 
00061         void ssl_connect();
00062 
00063         void ssl_accept();
00064 
00072         void set_client_mode();
00073 
00081         void set_server_mode();
00082 
00084         Context::pointer context();
00085 
00087         void set_context( Context::pointer context );
00088 
00093         bool clear();
00094 
00103         bool ssl_shutdown( bool bidirectional=false );
00104 
00105         
00112         bool use_certificate ( X509 *x );
00113 
00118         bool use_certificate_asn1 ( unsigned char *d, int len );
00119 
00126         bool use_certificate_file ( const std::string& file, FileType type );
00127 
00136         bool use_private_key ( EVP_PKEY *pkey );
00137 
00141         bool use_private_key_asn1 ( int pk, unsigned char *d, long len );
00142 
00149         bool use_private_key_file ( const std::string& file, FileType type );
00150 
00159         bool use_rsa_private_key ( RSA *rsa );
00160 
00164         bool use_rsa_private_key_asn1 ( unsigned char *d, long len );
00165 
00172         bool use_rsa_private_key_file ( const std::string& file, FileType type );
00173 
00186         bool check_private_key() const;
00187 
00192         void set_verify_depth ( int depth );
00193 
00202         long verify_result();
00203 
00205         X509* peer_certificate();
00206 
00208         bool set_bio( BIO* read_bio=NULL, BIO* write_bio=NULL );
00209 
00211         void set_read_ahead( bool set=true );
00212 
00214         BIO* read_bio();
00215 
00217         BIO* write_bio();
00218         
00219         ::SSL* cobj();
00220 
00221       protected:
00222         ::SSL* m_cobj;
00223         Context::pointer m_context;
00224 
00225     };
00226 
00227   }
00228 
00229 }
00230 
00231 #endif

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