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

sslserver.hpp

00001 /************************************************************************************
00002  *    This file is part of the MynahSA streaming and archiving toolkit              *
00003  *    Copyright (C) 2006 Mynah-Software Ltd. All Rights Reserved.                   *
00004  *                                                                                  *
00005  *    This program is free software; you can redistribute it and/or modify          *
00006  *    it under the terms of the GNU General Public License, version 2               *
00007  *    as published by the Free Software Foundation.                                 *
00008  *                                                                                  *
00009  *    This program is distributed in the hope that it will be useful,               *
00010  *    but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00011  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00012  *    GNU General Public License for more details.                                  *
00013  *                                                                                  *
00014  *    You should have received a copy of the GNU General Public License along       *
00015  *    with this program; if not, write to the Free Software Foundation, Inc.,       *
00016  *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.                   *
00017  *                                                                                  *
00018  ************************************************************************************/
00019 
00020 #ifndef __ssl_server_h
00021 #define __ssl_server_h
00022 
00023 #include <string>
00024 #include <stdexcept>
00025 
00026 #include <openssl/ssl.h>
00027 #include <openssl/err.h>
00028 
00029 #include <mynahsa/sslconnectionmanager.hpp>
00030 
00031 #include <mynahsa/exceptionbase.hpp>
00032 
00033 
00034 #define ENABLE_THREADED_SERVER
00035 
00036 namespace MynahSA { 
00046   class SSLServer {
00047   public:
00053     SSLServer(SSLConnectionManager& sobj, 
00054               std::string cFile, 
00055               std::string kFile, 
00056               int port,
00057               std::string caFile="" );
00058   
00064     SSLServer(SSLConnectionManager& sobj, 
00065               X509* certp, 
00066               EVP_PKEY* pkeyp, 
00067               int port,
00068               std::string caFile="");
00069   
00070   
00072     ~SSLServer();
00073           
00078     void checkClients(int wait_t=0);
00079   
00080   private:
00081   
00082     
00088     void loadCerts(std::string cFile, std::string kFile);
00089   
00091     void createCTX(std::string serverCAFile);
00092   
00094     void bindPort(void);
00095   
00096   
00098     SSL_CTX *_ctx;
00099   
00101     int _port;
00102   
00104     int _master;
00105     
00107     SSLConnectionManager& _serverObject;
00108   };  
00109 };
00110 
00111 #endif