if (cbd->fd != -1) {
msg = rspamd_http_new_message (HTTP_REQUEST);
+ if (cbd->bk->protocol == MAP_PROTO_HTTPS) {
+ msg->flags |= RSPAMD_HTTP_FLAG_SSL;
+ }
+
if (cbd->check) {
msg->method = HTTP_HEAD;
}
RSPAMD_HTTP_CLIENT_SIMPLE,
RSPAMD_HTTP_CLIENT,
NULL,
- NULL);
+ cbd->map->cfg->libs_ctx->ssl_ctx);
write_http_request (cbd);
}
if (cbd->need_modify) {
/* Load data from the next backend */
- if (bk->protocol == MAP_PROTO_HTTP) {
+ if (bk->protocol == MAP_PROTO_HTTP || bk->protocol == MAP_PROTO_HTTPS) {
rspamd_map_http_read_callback (fd, what, cbd);
}
else {
}
else {
/* Check the next backend */
- if (bk->protocol == MAP_PROTO_HTTP) {
+ if (bk->protocol == MAP_PROTO_HTTP || bk->protocol == MAP_PROTO_HTTPS) {
rspamd_map_http_check_callback (fd, what, cbd);
}
else {
bk->protocol = MAP_PROTO_FILE;
- if (g_ascii_strncasecmp (pos, "http://",
- sizeof ("http://") - 1) == 0) {
+ if (g_ascii_strncasecmp (pos, "http://", sizeof ("http://") - 1) == 0) {
bk->protocol = MAP_PROTO_HTTP;
/* Include http:// */
bk->uri = g_strdup (pos);
pos += sizeof ("http://") - 1;
}
+ else if (g_ascii_strncasecmp (pos, "https://", sizeof ("https://") - 1) == 0) {
+ bk->protocol = MAP_PROTO_HTTPS;
+ /* Include http:// */
+ bk->uri = g_strdup (pos);
+ pos += sizeof ("https://") - 1;
+ }
else if (g_ascii_strncasecmp (pos, "file://", sizeof ("file://") -
1) == 0) {
pos += sizeof ("file://") - 1;
fdata->filename = g_strdup (bk->uri);
bk->data.fd = fdata;
}
- else if (bk->protocol == MAP_PROTO_HTTP) {
+ else if (bk->protocol == MAP_PROTO_HTTP || bk->protocol == MAP_PROTO_HTTPS) {
hdata = g_slice_alloc0 (sizeof (struct http_map_data));
memset (&up, 0, sizeof (up));
hdata->port = up.port;
}
else {
- hdata->port = 80;
+ if (bk->protocol == MAP_PROTO_HTTP) {
+ hdata->port = 80;
+ }
+ else {
+ hdata->port = 443;
+ }
}
if (up.field_set & 1 << UF_PATH) {
}
struct rspamd_ssl_connection *
-rspamd_ssl_connection_new (gpointer ssl_ctx)
+rspamd_ssl_connection_new (gpointer ssl_ctx, struct event_base *ev_base)
{
struct rspamd_ssl_connection *c;
g_assert (ssl_ctx != NULL);
c = g_slice_alloc0 (sizeof (*c));
c->ssl = SSL_new (ssl_ctx);
+ c->ev_base = ev_base;
return c;
}
conn->handler = handler;
conn->err_handler = err_handler;
conn->handler_data = handler_data;
- conn->ev_base = event_get_base (ev);
if (SSL_set_fd (conn->ssl, fd) != 1) {
return FALSE;
if (ret == 1) {
conn->state = ssl_conn_connected;
event_set (ev, fd, EV_WRITE, rspamd_ssl_event_handler, conn);
- event_base_set (conn->ev_base, ev);
+ if (conn->ev_base) {
+ event_base_set (conn->ev_base, ev);
+ }
event_add (ev, tv);
}
else {