diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-26 17:53:22 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-26 17:53:22 +0000 |
commit | 7c8f499a6c9ff1e9b59dfd0787edade968add1eb (patch) | |
tree | 05f595aec81c29fe8f9d3f1842f91fc3bf8e34ae /src/libutil/http.c | |
parent | 625aec042ca53fc3d98200809c5fe9b3cf4b3117 (diff) | |
download | rspamd-7c8f499a6c9ff1e9b59dfd0787edade968add1eb.tar.gz rspamd-7c8f499a6c9ff1e9b59dfd0787edade968add1eb.zip |
[Feature] Simplify HTTPCrypt client support
Diffstat (limited to 'src/libutil/http.c')
-rw-r--r-- | src/libutil/http.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/libutil/http.c b/src/libutil/http.c index 9a33b1a90..1a8a4b953 100644 --- a/src/libutil/http.c +++ b/src/libutil/http.c @@ -1909,8 +1909,15 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn priv->flags |= RSPAMD_HTTP_CONN_FLAG_ENCRYPTED; } - if (priv->local_key != NULL && msg->peer_key != NULL) { + if (msg->peer_key != NULL) { + if (priv->local_key == NULL) { + /* Automatically generate a temporary keypair */ + priv->local_key = rspamd_keypair_new (RSPAMD_KEYPAIR_KEX, + RSPAMD_CRYPTOBOX_MODE_25519); + } + encrypted = TRUE; + if (conn->cache) { rspamd_keypair_cache_process (conn->cache, priv->local_key, priv->msg->peer_key); @@ -2688,6 +2695,22 @@ rspamd_http_message_free (struct rspamd_http_message *msg) } void +rspamd_http_message_set_peer_key (struct rspamd_http_message *msg, + struct rspamd_cryptobox_pubkey *pk) +{ + if (msg->peer_key != NULL) { + rspamd_pubkey_unref (msg->peer_key); + } + + if (pk) { + msg->peer_key = rspamd_pubkey_ref (pk); + } + else { + msg->peer_key = NULL; + } +} + +void rspamd_http_message_add_header (struct rspamd_http_message *msg, const gchar *name, const gchar *value) |