• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

sslclient.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
00003 // 
00004 // This program is free software; you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation; either version 3 of the License, or
00007 // (at your option) any later version.
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
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00017 //
00018 
00019 #ifndef GNASH_LIBNET_SSL_H
00020 #define GNASH_LIBNET_SSL_H
00021 
00022 #ifdef HAVE_CONFIG_H
00023 #include "gnashconfig.h"
00024 #endif
00025 
00026 #include <string>
00027 #include <boost/array.hpp>
00028 #include <boost/shared_ptr.hpp>
00029 #include <boost/shared_array.hpp>
00030 #include <boost/scoped_array.hpp>
00031 #include <boost/cstdint.hpp>
00032 #include <sstream>
00033 
00034 #ifdef HAVE_OPENSSL_SSL_H
00035 #include <openssl/ssl.h>
00036 #include <openssl/err.h>
00037 #endif
00038 
00039 #include "cque.h"
00040 #include "network.h"
00041 #include "buffer.h"
00042 
00043 namespace gnash
00044 {
00045 
00046 // extern const char *ROOTPATH;
00047 extern const char *HOST;
00048 // extern const char *CA_LIST;
00049 // extern const char *RANDOM;
00050 // extern const char *KEYFILE;
00051 extern const size_t SSL_PASSWD_SIZE;
00052 
00053 class DSOEXPORT SSLClient
00054 {
00055 public:
00056     SSLClient();
00057     ~SSLClient();
00058 
00059     // Read bytes from the already opened SSL connection
00060     int sslRead(amf::Buffer &buf);
00061     int sslRead(boost::uint8_t *buf, size_t length);
00062     int sslRead(std::string &buf);
00063 
00064     // Write bytes to the already opened SSL connection
00065     int sslWrite(amf::Buffer &buf);
00066     int sslWrite(const boost::uint8_t *buf, size_t length);
00067     int sslWrite(std::string &buf);
00068 
00069     // Setup the Context for this connection
00070     bool sslSetupCTX();
00071     bool sslSetupCTX(std::string &keyfile, std::string &cafile);
00072     
00073     // Shutdown the Context for this connection
00074     bool sslShutdown();
00075 
00076     // sslConnect() is how the client connects to the server 
00077     bool sslConnect(int fd);
00078     bool sslConnect(int fd, std::string &hostname, short port);
00079 
00080     void setKeyfile(std::string filespec) { _keyfile = filespec; };
00081     std::string &getKeyfile() { return _keyfile; };
00082     
00083     void setCAlist(std::string filespec) { _calist = filespec; };
00084     std::string &getCAlist() { return _calist; };
00085     
00086     void setPassword(std::string pw);
00087     std::string &getPassword();
00088     
00089     void setCert(std::string filespec) { _cert = filespec; };
00090     std::string &getCert() { return _cert; };
00091     
00092     void setRootPath(std::string filespec) { _rootpath = filespec; };
00093     std::string &getRootPath() { return _rootpath; };
00094     
00095     void setPem(std::string filespec) { _pem = filespec; };
00096     std::string &getPem() { return _pem; };
00097     
00098     void setHostname(std::string name) { _hostname = name; };
00099     std::string &getHostname() { return _hostname; };
00100     
00101     void setServerAuth(bool flag) { _need_server_auth = flag; };
00102     bool getServerAuth() { return _need_server_auth; };
00103     
00104     // Check a certificate
00105     bool checkCert();
00106     bool checkCert(std::string &hostname);
00107 
00108     void dump();
00109  protected:
00110     boost::scoped_ptr<SSL> _ssl;
00111     boost::scoped_ptr<SSL_CTX> _ctx;
00112     boost::scoped_ptr<BIO> _bio;
00113     boost::scoped_ptr<BIO> _bio_error;
00114     std::string         _hostname;
00115     std::string         _calist;
00116     std::string         _keyfile;
00117     std::string         _cert;
00118     std::string         _pem;
00119     std::string         _rootpath;
00120     bool                _need_server_auth;
00121 };
00122 
00123 extern "C" {
00124     // This is the callback required when setting up the password
00125     int password_cb(char *buf, int size, int rwflag, void *userdata);
00126     int verify_callback(int ok, X509_STORE_CTX *store);
00127 }
00128 
00129 
00130 } // end of gnash namespace
00131 
00132 // end of _SSL_H_
00133 #endif
00134 
00135 
00136 // local Variables:
00137 // mode: C++
00138 // indent-tabs-mode: t
00139 // End:

Generated on Fri Mar 16 2012 15:46:12 for Gnash by  doxygen 1.7.1