using namespace std;
sqlpg::sqlpg() {
- /* Load the human readable error strings for libcrypto */
- ERR_load_crypto_strings();
- /* Load all digest and cipher algorithms */
+ //src : http://www.ibm.com/developerworks/linux/library/l-openssl/index.html
+ SSL_load_error_strings();
+ ERR_load_BIO_strings();
OpenSSL_add_all_algorithms();
- /* Load config file, and other important initialisation */
- OPENSSL_config(NULL);
- EVP_PKEY *EVP_PKEY_new(void);
+ SSL_library_init();
//strconnect = "host=postgresql1.alwaysdata.com port=5432 dbname=nothing2do.eu_diary user=nothing2do.eu password=x connect_timeout=10";
strconnect = "dbname=bob user=bob password=pass connect_timeout=10";
};
clog<<"value.size="<<value.size()<<endl;
};
-void sqlpg::connect(string service, string name){//I mean "username" but i'm scared to user "username" cause pgsql interpret it ...
+void sqlpg::connect(string service, string name){//I mean "username" but i'm affraid that the string "username" get caught by pgsql ...
clog<<"connect start here\n";
string nom="getpass", as=toString(2), i;
int argca=2;//it won't work if I use argca in place of 2 :-(
string pass=PQgetvalue(res, 0, PQfnumber(res, "password"));
clog<<"service="<<service<<" user="<<name<<" pass="<<pass<<endl;
+ string str="jarvis.nothing2do.eu:22";
+ bio = BIO_new_connect(str.c_str());
+ if(bio == NULL)
+ {
+ /* Handle the failure */
+ }
+
+ if(BIO_do_connect(bio) <= 0)
+ {
+ /* Handle failed connection */
+ }
+\r
+ ERR_load_BIO_strings();\r
+ SSL_load_error_strings();\r
+ OpenSSL_add_all_algorithms();
}
#include <vector>
#include <cstdio>
#include <map>
-#include <openssl/conf.h>
-#include <openssl/evp.h>
+/*#include <openssl/conf.h>
+#include <openssl/evp.h>*/
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/bio.h>
void connect(std::string, std::string);//connect with user and service (credential in database)
private:
+ BIO * bio;
+ SSL * ssl;
+ SSL_CTX * ctx;
PGconn *conn;
PGresult *res, *res2, *res3;
std::vector < std::vector<std::string> > ret;//useless ?