Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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
00047 extern const char *HOST;
00048
00049
00050
00051 extern const size_t SSL_PASSWD_SIZE;
00052
00053 class DSOEXPORT SSLClient
00054 {
00055 public:
00056 SSLClient();
00057 ~SSLClient();
00058
00059
00060 int sslRead(amf::Buffer &buf);
00061 int sslRead(boost::uint8_t *buf, size_t length);
00062 int sslRead(std::string &buf);
00063
00064
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
00070 bool sslSetupCTX();
00071 bool sslSetupCTX(std::string &keyfile, std::string &cafile);
00072
00073
00074 bool sslShutdown();
00075
00076
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
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
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 }
00131
00132
00133 #endif
00134
00135
00136
00137
00138
00139