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.
CHECK_AND_ASSERT_THROW_MES(private_key_and_certificate_path.first.empty()==private_key_and_certificate_path.second.empty(),"private key and certificate must be either both given or both empty");
constcommand_line::arg_descriptor<std::string>daemon_ssl_private_key={"daemon-ssl-private-key",tools::wallet2::tr("Path to a PEM format private key"),""};
constcommand_line::arg_descriptor<std::string>daemon_ssl_certificate={"daemon-ssl-certificate",tools::wallet2::tr("Path to a PEM format certificate"),""};
constcommand_line::arg_descriptor<std::vector<std::string>>daemon_ssl_allowed_certificates={"daemon-ssl-allowed-certificates",tools::wallet2::tr("List of paths to PEM format certificates of allowed RPC servers")};
constcommand_line::arg_descriptor<std::vector<std::string>>daemon_ssl_allowed_fingerprints={"daemon-ssl-allowed-fingerprints",tools::wallet2::tr("List of valid fingerprints of allowed RPC servers")};
constcommand_line::arg_descriptor<bool>daemon_ssl_allow_any_cert={"daemon-ssl-allow-any-cert",tools::wallet2::tr("Allow any SSL certificate from the daemon"),false};
constcommand_line::arg_descriptor<bool>testnet={"testnet",tools::wallet2::tr("For testnet. Daemon must also be launched with --testnet flag"),false};
constcommand_line::arg_descriptor<bool>stagenet={"stagenet",tools::wallet2::tr("For stagenet. Daemon must also be launched with --stagenet flag"),false};
constcommand_line::arg_descriptor<std::string>arg_rpc_ssl_private_key={"rpc-ssl-private-key",tools::wallet2::tr("Path to a PEM format private key"),""};
constcommand_line::arg_descriptor<std::string>arg_rpc_ssl_certificate={"rpc-ssl-certificate",tools::wallet2::tr("Path to a PEM format certificate"),""};
constcommand_line::arg_descriptor<std::vector<std::string>>arg_rpc_ssl_allowed_certificates={"rpc-ssl-allowed-certificates",tools::wallet2::tr("List of paths to PEM format certificates of allowed RPC servers (all allowed if empty)")};
constcommand_line::arg_descriptor<std::vector<std::string>>arg_rpc_ssl_allowed_fingerprints={"rpc-ssl-allowed-fingerprints",tools::wallet2::tr("List of certificate fingerprints to allow")};