]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: Allow http_client_settings.ssl==NULL
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 8 May 2016 19:22:25 +0000 (22:22 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 8 May 2016 19:24:47 +0000 (22:24 +0300)
src/lib-http/http-client.c

index d2d0a648d911ef136160ba57fd24cb55a70f3b4a..b5db1b57bf2775fa12f286b962f5252432a0fe12 100644 (file)
@@ -99,7 +99,8 @@ struct http_client *http_client_init(const struct http_client_settings *set)
        client->set.user_agent = p_strdup_empty(pool, set->user_agent);
        client->set.rawlog_dir = p_strdup_empty(pool, set->rawlog_dir);
 
-       client->set.ssl = ssl_iostream_settings_dup(client->pool, set->ssl);
+       if (set->ssl != NULL)
+               client->set.ssl = ssl_iostream_settings_dup(client->pool, set->ssl);
 
        if (set->proxy_socket_path != NULL && *set->proxy_socket_path != '\0') {
                client->set.proxy_socket_path = p_strdup(pool, set->proxy_socket_path);
@@ -278,6 +279,10 @@ int http_client_init_ssl_ctx(struct http_client *client, const char **error_r)
        if (client->ssl_ctx != NULL)
                return 0;
 
+       if (client->set.ssl == NULL) {
+               *error_r = "Requested https connection, but no SSL settings given";
+               return -1;
+       }
        if (ssl_iostream_context_init_client(client->set.ssl, &client->ssl_ctx, &error) < 0) {
                *error_r = t_strdup_printf("Couldn't initialize SSL context: %s",
                                           error);