Created
August 30, 2014 23:02
error_test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* compile with | |
gcc -ggdb -O0 -lssl -lcrypto -ldl -pthread -o ssltest error_test.cpp | |
*/ | |
#include <openssl/ssl.h> | |
#include <dlfcn.h> | |
#include <pthread.h> | |
static void *lib = 0; | |
static int (*initfunc)(int,char**,char**); | |
static void (*endfunc)(void); | |
static void loadIt() | |
{ | |
lib = dlopen("libmysqlclient.so.18", RTLD_LAZY); | |
initfunc = (int(*)(int,char**,char**))dlsym(lib, "mysql_server_init"); | |
endfunc = (void(*)(void))dlsym(lib, "mysql_server_end"); | |
} | |
static void unloadIt() | |
{ | |
initfunc = 0; | |
dlclose(lib); | |
lib = 0; | |
} | |
int main(int argc, char *argv[]) | |
{ | |
SSL_CTX *ctx = NULL; | |
SSL_library_init(); | |
ctx = SSL_CTX_new(SSLv23_client_method()); | |
printf("before init ctx is %p\n", ctx); | |
loadIt(); | |
initfunc(0, 0, 0); | |
endfunc(); | |
unloadIt(); | |
ctx = SSL_CTX_new(SSLv23_client_method()); | |
printf("after init ctx is %p\n", ctx); | |
SSL_library_init(); | |
ctx = SSL_CTX_new(SSLv23_client_method()); | |
printf("after SSL reinit ctx is %p\n", ctx); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment