Currently it only works on server side. bitcoin-cli needs probably a complete rewrite to work, see more below
Abstract
The goal of this PR is to add full functional SSL support to the Bitcoin Core HTTP Server.
Motivation
At the moment it is not really secure to use Bitcoin Core RPC remotely. (#12763) made it much more secure with restricting access. However the connection level side is still insecure as it works through plain HTTP.
The bitcoin-cli problem
The reason why I am opening this PR in this early state is because it seems like bitcoin-cli will need a rewrite powered by libcurl as libevent has not really good SSL support on the client side (other ideas and help is most welcome). As such a change is major I already wanna ask for r"Concept (N)?ACK" so that such a major change won't be worthless.
OpenSSL again
This PR adds OpenSSL again. I would like if @fanquake could review the first two commits as they mostly consist of reverts from two of his PRs (#17265 and #17165)
Testing
It is already testable. Please be sure to have OpenSSL installed on your system! (Debian: apt install openssl libssl-dev)
You should also have cURL installed.
The actual testing
- Generate an SSL cert with
openssl req -nodes -new -x509 -keyout server.key -out server.cert. If you have problems with the generation, you can download mine. (DO NOT USE THEM PRODUCTIVELY AS THE PRIVATE KEY IS PUBLICLY AVAILABLE). Download here - Compile my branch
- Start bitcoind with
./bitcoind --server=1 --rpcuser=u --rpcpassword=p --regtest --ssl=1 --sslcert=/home/emil/openssl/server.cert --sslkey=/home/emil/openssl/server.key
(Please adjust the paths according to yours)
4. Do the SSL request (Enter p as password)!
curl --user u -k --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getbestblockhash", "params": [] }' -H 'content-type: text/plain;' https://127.0.0.1:18443/
- You should see that you just made a successful HTTPS request