]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add aux method to disable HTTP encryptipon
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 24 Jun 2018 19:18:25 +0000 (20:18 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 24 Jun 2018 19:18:25 +0000 (20:18 +0100)
src/libutil/http.c
src/libutil/http.h
src/rspamd_proxy.c

index 3155988710e651064394117b0c8e83c5748fa790..974a2b592579c9cbd7553eb64ff91d702c87e573 100644 (file)
@@ -850,7 +850,8 @@ rspamd_http_decrypt_message (struct rspamd_http_connection *conn,
 
        if (!rspamd_cryptobox_decrypt_nm_inplace (m, dec_len, nonce,
                        nm, m - rspamd_cryptobox_mac_bytes (mode), mode)) {
-               msg_err ("cannot verify encrypted message");
+               msg_err ("cannot verify encrypted message, first bytes of the input: %*xs",
+                               (gint)MIN(msg->body_buf.len, 64), msg->body_buf.begin);
                return -1;
        }
 
@@ -3936,3 +3937,24 @@ rspamd_http_normalize_path_inplace (gchar *path, guint len, guint *nlen)
                *nlen = (o - path);
        }
 }
+
+void
+rspamd_http_connection_disable_encryption (struct rspamd_http_connection *conn)
+{
+       struct rspamd_http_connection_private *priv;
+
+       priv = conn->priv;
+
+       if (priv) {
+               if (priv->local_key) {
+                       rspamd_keypair_unref (priv->local_key);
+               }
+               if (priv->peer_key) {
+                       rspamd_pubkey_unref (priv->peer_key);
+               }
+
+               priv->local_key = NULL;
+               priv->peer_key = NULL;
+               priv->flags &= ~RSPAMD_HTTP_CONN_FLAG_ENCRYPTED;
+       }
+}
\ No newline at end of file
index 4ce9e0a84763fd48655aedb5e206424708f75dfd..c271caaa40ad1252dc885c6e1d013a5987116ec2 100644 (file)
@@ -438,6 +438,8 @@ void rspamd_http_message_free (struct rspamd_http_message *msg);
 void rspamd_http_connection_set_max_size (struct rspamd_http_connection *conn,
                gsize sz);
 
+void rspamd_http_connection_disable_encryption (struct rspamd_http_connection *conn);
+
 /**
  * Increase refcount for shared file (if any) to prevent early memory unlinking
  * @param msg
index 5ec9cdce2d76629c0f120f3ffbdda8ea82819af3..1d4324bdcfb7b5d6cb840acc4edbb2b86bcf5aa8 100644 (file)
@@ -1499,10 +1499,10 @@ proxy_backend_master_error_handler (struct rspamd_http_connection *conn, GError
        struct rspamd_proxy_session *session;
 
        session = bk_conn->s;
-       msg_info_session ("abnormally closing connection from backend: %s, error: %s,"
+       msg_info_session ("abnormally closing connection from backend: %s, error: %e,"
                        " retries left: %d",
                rspamd_inet_address_to_string (rspamd_upstream_addr (session->master_conn->up)),
-               err->message,
+               err,
                session->ctx->max_retries - session->retries);
        session->retries ++;
        rspamd_upstream_fail (bk_conn->up);