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

sslrpcclient.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_rpc_client_hpp
00021 #define __ssl_rpc_client_hpp
00022 
00023 
00024 #include "iobase.hpp"
00025 
00026 
00027 
00028 
00029 
00030 #include <openssl/crypto.h>
00031 #include <openssl/x509.h>
00032 #include <openssl/pem.h>
00033 #include <openssl/ssl.h>
00034 #include <openssl/err.h>
00035 
00036 #include "sslarchivestream.hpp"
00037 #include "streamconstructor.hpp"
00038 
00039 #include <string>
00040 
00041 #include <mynahsa/spimpl.hpp>
00042 
00043 
00044 
00045 namespace MynahSA { 
00046 
00052   class SSLRPCClient {
00053   public:
00061     SSLRPCClient(const StreamConstructor& sc,
00062                 unsigned int ipaddress, 
00063                 unsigned int port,
00064                 std::string certificateFile="",
00065                 std::string privateKeyFile="");
00066     
00074     SSLRPCClient(const StreamConstructor& sc,
00075                  std::string machineName, 
00076                  unsigned int port,
00077                  std::string certificateFile="",
00078                  std::string privateKeyFile="");
00079     
00080     
00082     ~SSLRPCClient();
00083   
00085     SHARED_PTR<IoBase> rpc(SHARED_PTR<IoBase> req);
00086   
00088     bool is_open() const { return _isopen; }
00089   
00091     void close();
00092   
00093   
00094   private:
00096     void init(const StreamConstructor& sc,
00097               unsigned int ipaddress, 
00098               unsigned int port,
00099               std::string certificateFile="",
00100               std::string privateKeyFile="");
00101   
00103     bool _isopen;
00104     
00106     SSL_CTX*    _ctx;
00107     
00109     SSL*        _ssl;
00110     
00112     X509*       _serverCert;
00113     
00115     int         _sd;
00116   
00118     SHARED_PTR<SSLArchiveStream> _stream;
00119   
00120   
00121   };
00122 };
00123 
00124 #endif