diff --git a/lib/irc.h b/lib/irc.h index 2540b99..da5f13a 100755 --- a/lib/irc.h +++ b/lib/irc.h @@ -36,6 +36,7 @@ struct irc_conn #else FILE *srv_fd; #endif + char ssl_module[256]; char nick[50]; char user[50]; char admin[256]; diff --git a/mods/openssl.dll b/mods/openssl.dll index 6b88717..0ae4fcf 100755 Binary files a/mods/openssl.dll and b/mods/openssl.dll differ diff --git a/mods/openssl.lib b/mods/openssl.lib index 3055209..fcf744f 100755 Binary files a/mods/openssl.lib and b/mods/openssl.lib differ diff --git a/mods/openssl/openssl.c b/mods/openssl/openssl.c index 5302e8b..694e3a0 100755 --- a/mods/openssl/openssl.c +++ b/mods/openssl/openssl.c @@ -15,8 +15,10 @@ int ssl_fd; SSL *ssl; SSL_CTX *ctx; -MY_API void sslmod_init(struct irc_conn *bot) +MY_API void sslmod_init() { + struct irc_conn *bot = get_bot(); + SSL_library_init(); SSL_load_error_strings(); ctx = SSL_CTX_new(SSLv23_client_method()); @@ -25,12 +27,14 @@ MY_API void sslmod_init(struct irc_conn *bot) eprint("Error: Cannot create SSL context\n"); } - if (bot->verify_ssl) + if (bot->verify_ssl == true) { + printf("SSL: Verifying server certificate\n"); SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, NULL); } else { + printf("SSL: Not verifying server certificate\n"); SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL); } @@ -42,12 +46,12 @@ MY_API void sslmod_init(struct irc_conn *bot) MY_API int get_ssl_fd() { - printf("ssl_fd: %d\n", ssl_fd); return ssl_fd; } MY_API void sslmod_connect() { + unsigned long ssl_err; struct irc_conn *bot = get_bot(); #ifdef _WIN32 @@ -62,6 +66,12 @@ MY_API void sslmod_connect() if (SSL_connect(ssl) != 1) { eprint("Error: Cannot connect to SSL server\n"); + + ssl_err = ERR_get_error(); + if (ssl_err) + { + eprint("SSL error: %s\n", ERR_error_string(ssl_err, NULL)); + } } #ifdef _WIN32 diff --git a/src/config.c b/src/config.c index 307eab4..a6bbca0 100755 --- a/src/config.c +++ b/src/config.c @@ -14,8 +14,9 @@ struct irc_conn read_config(struct irc_conn bot, char *file) const char *base = (const char*)malloc(sizeof(char) * 1024); const char *mod = NULL; int boolbase; - char *modpath = (char *)malloc(sizeof(char) * 500); + bot.verify_ssl = 0; + bot.use_ssl = 0; cf = &cfg; config_init(cf); @@ -90,6 +91,22 @@ void run_autoload(struct irc_conn *bot) exit(-1); } + if (bot->use_ssl) + { + if (config_lookup_string(cf, "server.ssl_module", &base)) + { + strlcpy(bot->ssl_module, base, sizeof bot->ssl_module); + + // Load the SSL module +#ifdef _WIN32 + sprintf(modpath, "./mods/%s.dll", bot->ssl_module); +#else + sprintf(modpath, "./mods/%s.so", bot->ssl_module); +#endif + load_module(bot, "main", "runtime", modpath); + } + } + autoload = config_lookup(cf, "mods.autoload"); count = config_setting_length(autoload); @@ -105,4 +122,5 @@ void run_autoload(struct irc_conn *bot) } config_destroy(cf); + free(modpath); } diff --git a/xbot.cfg b/xbot.cfg index d16b2c9..15b0446 100755 --- a/xbot.cfg +++ b/xbot.cfg @@ -20,9 +20,11 @@ bot: server: { host = "memphis.ephasic.org"; - port = "6667"; + port = "6697"; - ssl = false; + # ssl options + ssl = true; + ssl_module = "openssl"; ssl_verify = false; };