From 43b0d36ee182f48cd655187a63411045aa04c948 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 16 Nov 2003 17:53:55 +0000 Subject: Support for sending SSL certificate to server and optionally verify server's certificate. See the -ssl_* options for /SERVER and /SERVER ADD. Patch by Joel Eriksson . git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3146 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/core/chat-commands.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'src/core/chat-commands.c') diff --git a/src/core/chat-commands.c b/src/core/chat-commands.c index 16c3a0e9..ad9313ed 100644 --- a/src/core/chat-commands.c +++ b/src/core/chat-commands.c @@ -40,7 +40,7 @@ static SERVER_CONNECT_REC *get_server_connect(const char *data, int *plus_addr, CHAT_PROTOCOL_REC *proto; SERVER_CONNECT_REC *conn; GHashTable *optlist; - char *addr, *portstr, *password, *nick, *chatnet, *host; + char *addr, *portstr, *password, *nick, *chatnet, *host, *tmp; void *free_arg; g_return_val_if_fail(data != NULL, NULL); @@ -88,7 +88,22 @@ static SERVER_CONNECT_REC *get_server_connect(const char *data, int *plus_addr, else if (g_hash_table_lookup(optlist, "4") != NULL) conn->family = AF_INET; - if(g_hash_table_lookup(optlist, "ssl") != NULL) + if (g_hash_table_lookup(optlist, "ssl") != NULL) + conn->use_ssl = TRUE; + if ((tmp = g_hash_table_lookup(optlist, "ssl_cert")) != NULL) + conn->ssl_cert = g_strdup(tmp); + if ((tmp = g_hash_table_lookup(optlist, "ssl_pkey")) != NULL) + conn->ssl_pkey = g_strdup(tmp); + if (g_hash_table_lookup(optlist, "ssl_verify") != NULL) + conn->ssl_verify = TRUE; + if ((tmp = g_hash_table_lookup(optlist, "ssl_cafile")) != NULL) + conn->ssl_cafile = g_strdup(tmp); + if ((tmp = g_hash_table_lookup(optlist, "ssl_capath")) != NULL) + conn->ssl_capath = g_strdup(tmp); + if ((conn->ssl_capath != NULL && conn->ssl_capath[0] != '\0') + || (conn->ssl_cafile != NULL && conn->ssl_cafile[0] != '\0')) + conn->ssl_verify = TRUE; + if ((conn->ssl_cert != NULL && conn->ssl_cert[0] != '\0') || conn->ssl_verify) conn->use_ssl = TRUE; if (g_hash_table_lookup(optlist, "!") != NULL) @@ -112,9 +127,11 @@ static SERVER_CONNECT_REC *get_server_connect(const char *data, int *plus_addr, return conn; } -/* SYNTAX: CONNECT [-4 | -6] [-ssl] [-noproxy] [-ircnet ] - [-host ] [-rawlog ] -
| [ [ []]] */ +/* SYNTAX: CONNECT [-4 | -6] [-ssl] [-ssl_cert ] [-ssl_pkey ] + [-ssl_verify] [-ssl_cafile ] [-ssl_capath ] + [-noproxy] [-ircnet ] [-host ] + [-rawlog ] +
| [ [ []]] */ static void cmd_connect(const char *data) { SERVER_CONNECT_REC *conn; @@ -214,8 +231,10 @@ static void sig_default_command_server(const char *data, SERVER_REC *server, signal_emit("command server connect", 3, data, server, item); } -/* SYNTAX: SERVER [-4 | -6] [-ssl] [-noproxy] [-ircnet ] - [-host ] [-rawlog ] +/* SYNTAX: SERVER [-4 | -6] [-ssl] [-ssl_cert ] [-ssl_pkey ] + [-ssl_verify] [-ssl_cafile ] [-ssl_capath ] + [-noproxy] [-ircnet ] [-host ] + [-rawlog ] [+]
| [ [ []]] */ static void cmd_server_connect(const char *data, SERVER_REC *server) { @@ -445,7 +464,7 @@ void chat_commands_init(void) signal_add("default command server", (SIGNAL_FUNC) sig_default_command_server); - command_set_options("connect", "4 6 !! ssl +host noproxy -rawlog"); + command_set_options("connect", "4 6 !! ssl +ssl_cert +ssl_pkey ssl_verify +ssl_cafile +ssl_capath +host noproxy -rawlog"); command_set_options("join", "invite"); command_set_options("msg", "channel nick"); } -- cgit v1.2.3