aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartijn Otto <git@martijnotto.nl>2018-06-14 23:44:48 +0100
committerMartijn Otto <git@martijnotto.nl>2019-03-05 14:16:08 +0100
commit057c279cb4d5c16990570d281bd1bc568796cbb2 (patch)
tree53d81098e4a1364da5bee1507a0b8c079d269777 /tests
parentMerge pull request #5231 (diff)
downloadmonero-057c279cb4d5c16990570d281bd1bc568796cbb2.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 'tests')
-rw-r--r--tests/unit_tests/epee_utils.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/unit_tests/epee_utils.cpp b/tests/unit_tests/epee_utils.cpp
index 18fb262c2..9a32d149a 100644
--- a/tests/unit_tests/epee_utils.cpp
+++ b/tests/unit_tests/epee_utils.cpp
@@ -389,6 +389,25 @@ TEST(ToHex, String)
}
+TEST(FromHex, String)
+{
+ // the source data to encode and decode
+ std::vector<uint8_t> source{{ 0x00, 0xFF, 0x0F, 0xF0 }};
+
+ // encode and decode the data
+ auto hex = epee::to_hex::string({ source.data(), source.size() });
+ auto decoded = epee::from_hex::vector(hex);
+
+ // encoded should be twice the size and should decode to the exact same data
+ EXPECT_EQ(source.size() * 2, hex.size());
+ EXPECT_EQ(source, decoded);
+
+ // we will now create a padded hex string, we want to explicitly allow
+ // decoding it this way also, ignoring spaces and colons between the numbers
+ hex.assign("00:ff 0f:f0");
+ EXPECT_EQ(source, epee::from_hex::vector(hex));
+}
+
TEST(ToHex, Array)
{
EXPECT_EQ(