aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include/net/net_utils_base.h
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-06-14 23:44:48 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-02-02 20:05:33 +0000
commit24569454086a366e0bd0cd9b33b0b34661fe7af8 (patch)
treebe64b89e06a821d3490e4a142297e12aa435ed19 /contrib/epee/include/net/net_utils_base.h
parentMerge pull request #4988 (diff)
downloadmonero-24569454086a366e0bd0cd9b33b0b34661fe7af8.tar.xz
epee: add SSL support
RPC connections now have optional tranparent SSL. An optional private key and certificate file can be passed, using the --{rpc,daemon}-ssl-private-key and --{rpc,daemon}-ssl-certificate options. Those have as argument a path to a PEM format private private key and certificate, respectively. If not given, a temporary self signed certificate will be used. SSL can be enabled or disabled using --{rpc}-ssl, which accepts autodetect (default), disabled or enabled. Access can be restricted to particular certificates using the --rpc-ssl-allowed-certificates, which takes a list of paths to PEM encoded certificates. This can allow a wallet to connect to only the daemon they think they're connected to, by forcing SSL and listing the paths to the known good certificates. To generate long term certificates: openssl genrsa -out /tmp/KEY 4096 openssl req -new -key /tmp/KEY -out /tmp/REQ openssl x509 -req -days 999999 -sha256 -in /tmp/REQ -signkey /tmp/KEY -out /tmp/CERT /tmp/KEY is the private key, and /tmp/CERT is the certificate, both in PEM format. /tmp/REQ can be removed. Adjust the last command to set expiration date, etc, as needed. It doesn't make a whole lot of sense for monero anyway, since most servers will run with one time temporary self signed certificates anyway. SSL support is transparent, so all communication is done on the existing ports, with SSL autodetection. This means you can start using an SSL daemon now, but you should not enforce SSL yet or nothing will talk to you.
Diffstat (limited to 'contrib/epee/include/net/net_utils_base.h')
-rw-r--r--contrib/epee/include/net/net_utils_base.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/contrib/epee/include/net/net_utils_base.h b/contrib/epee/include/net/net_utils_base.h
index 82f8a7fe8..7ee0106b1 100644
--- a/contrib/epee/include/net/net_utils_base.h
+++ b/contrib/epee/include/net/net_utils_base.h
@@ -241,6 +241,7 @@ namespace net_utils
const network_address m_remote_address;
const bool m_is_income;
const time_t m_started;
+ const time_t m_ssl;
time_t m_last_recv;
time_t m_last_send;
uint64_t m_recv_cnt;
@@ -251,13 +252,14 @@ namespace net_utils
double m_max_speed_up;
connection_context_base(boost::uuids::uuid connection_id,
- const network_address &remote_address, bool is_income,
+ const network_address &remote_address, bool is_income, bool ssl,
time_t last_recv = 0, time_t last_send = 0,
uint64_t recv_cnt = 0, uint64_t send_cnt = 0):
m_connection_id(connection_id),
m_remote_address(remote_address),
m_is_income(is_income),
m_started(time(NULL)),
+ m_ssl(ssl),
m_last_recv(last_recv),
m_last_send(last_send),
m_recv_cnt(recv_cnt),
@@ -272,6 +274,7 @@ namespace net_utils
m_remote_address(),
m_is_income(false),
m_started(time(NULL)),
+ m_ssl(false),
m_last_recv(0),
m_last_send(0),
m_recv_cnt(0),
@@ -284,17 +287,17 @@ namespace net_utils
connection_context_base& operator=(const connection_context_base& a)
{
- set_details(a.m_connection_id, a.m_remote_address, a.m_is_income);
+ set_details(a.m_connection_id, a.m_remote_address, a.m_is_income, a.m_ssl);
return *this;
}
private:
template<class t_protocol_handler>
friend class connection;
- void set_details(boost::uuids::uuid connection_id, const network_address &remote_address, bool is_income)
+ void set_details(boost::uuids::uuid connection_id, const network_address &remote_address, bool is_income, bool ssl)
{
this->~connection_context_base();
- new(this) connection_context_base(connection_id, remote_address, is_income);
+ new(this) connection_context_base(connection_id, remote_address, is_income, ssl);
}
};