# HG changeset patch # User Timo Sirainen # Date 1410189091 -10800 # Node ID bf1faf8ab847d3e0b39e2153a8c923528978b551 # Parent a41089e5bd8e6f17ba3f98f765468eab519779d2 pop3c: Added missing support for pop3c_ssl=starttls diff -r a41089e5bd8e -r bf1faf8ab847 src/lib-storage/index/pop3c/pop3c-client.c --- a/src/lib-storage/index/pop3c/pop3c-client.c Mon Sep 08 13:39:25 2014 +0300 +++ b/src/lib-storage/index/pop3c/pop3c-client.c Mon Sep 08 18:11:31 2014 +0300 @@ -27,6 +27,7 @@ POP3C_CLIENT_STATE_DISCONNECTED = 0, /* Trying to connect */ POP3C_CLIENT_STATE_CONNECTING, + POP3C_CLIENT_STATE_STARTTLS, /* Connected, trying to authenticate */ POP3C_CLIENT_STATE_USER, POP3C_CLIENT_STATE_AUTH, @@ -68,6 +69,7 @@ pop3c_dns_callback(const struct dns_lookup_result *result, struct pop3c_client *client); static void pop3c_client_connect_ip(struct pop3c_client *client); +static int pop3c_client_ssl_init(struct pop3c_client *client); struct pop3c_client * pop3c_client_init(const struct pop3c_client_settings *set) @@ -267,6 +269,12 @@ io_loop_destroy(&ioloop); } +static void pop3c_client_starttls(struct pop3c_client *client) +{ + o_stream_nsend_str(client->output, "STLS\r\n"); + client->state = POP3C_CLIENT_STATE_STARTTLS; +} + static void pop3c_client_authenticate1(struct pop3c_client *client) { const struct pop3c_client_settings *set = &client->set; @@ -339,7 +347,19 @@ client->set.host, line); return -1; } - pop3c_client_authenticate1(client); + if (client->set.ssl_mode == POP3C_CLIENT_SSL_MODE_STARTTLS) + pop3c_client_starttls(client); + else + pop3c_client_authenticate1(client); + break; + case POP3C_CLIENT_STATE_STARTTLS: + if (!success) { + i_error("pop3c(%s): STLS failed: %s", + client->set.host, line); + return -1; + } + if (pop3c_client_ssl_init(client) < 0) + pop3c_client_disconnect(client); break; case POP3C_CLIENT_STATE_USER: if (!success) {