Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote RPC: enable https #424

Merged
merged 5 commits into from
Dec 23, 2021
Merged

Remote RPC: enable https #424

merged 5 commits into from
Dec 23, 2021

Conversation

pinheadmz
Copy link
Contributor

@pinheadmz pinheadmz commented Oct 27, 2021

Closes #411

Reviewers can test by opening Bob in dev mode in REGTEST and configuring my hosted regtest node as the remote:

protocol: https
host: hns-contributor.dev
path:
Network Type: Regtest
port: 14037
API key: hellogoodbye-whatsmyname-123

There is one stupid hack here because in hsd WalletNode has no option for path so if pathname is set by user, we have to assemble a URL and pass that as the nodeURL option to WalletNode 🤷‍♂️

TODO:

  • test with path: I'm having trouble setting up a reverse proxy for this just to test an alternate path
  • clean up RPC config modal: the placeholders look like values and you have to re-type to enter data

LONG-TERM TODO: Allow self-signed cert pinning so remote rpc can connect over https without legacy CA

- prohibit remote over http
- remove network switcher: use wallet's network property
- autofill port based on network
- set default values as actual values instead of placeholders
@pinheadmz
Copy link
Contributor Author

Fun fact about this: since all the parameters are set with network defaults, if the user opens the modal and paste in the Bob Wallet API key and hits save, It will actually test connect to the internal full node, see the connection is valid and then proceed with remote RPC mode, which means shutting the internal node down! Resulting in a no connection error.

@chikeichan chikeichan merged commit bf50e44 into kyokan:master Dec 23, 2021
@rithvikvibhu
Copy link
Collaborator

test with path: I'm having trouble setting up a reverse proxy for this just to test an alternate path

Tried this and the HTTP part works (and Bob passes the RPC test), but websocket says 404 with this nginx config:

nodeclient error Error: Error during WebSocket handshake: Unexpected response code: 404
    at Socket.onError (/media/data/Projects/handshake/bob-wallet/node_modules/bsock/lib/socket.js:245:24)
    at Client.ws.onerror (/media/data/Projects/handshake/bob-wallet/node_modules/bsock/lib/socket.js:174:18)
    at Client.dispatchEvent (/media/data/Projects/handshake/bob-wallet/node_modules/bsock/vendor/faye-websocket.js:3179:30)
    at Client._emitError (/media/data/Projects/handshake/bob-wallet/node_modules/bsock/vendor/faye-websocket.js:3117:10)
    at Client.<anonymous> (/media/data/Projects/handshake/bob-wallet/node_modules/bsock/vendor/faye-websocket.js:2996:10)
    at Client.emit (node:events:402:35)
    at Client.emit (node:domain:475:12)
    at Client._failHandshake (/media/data/Projects/handshake/bob-wallet/node_modules/bsock/vendor/faye-websocket.js:769:10)
    at Client._validateHandshake (/media/data/Projects/handshake/bob-wallet/node_modules/bsock/vendor/faye-websocket.js:781:19)
    at Client.parse (/media/data/Projects/handshake/bob-wallet/node_modules/bsock/vendor/faye-websocket.js:748:10)

Start hsd with:

hsd --network regtest --no-dns --no-wallet --http-host 0.0.0.0 --api-key apikeyhere

nginx config:

server {
    listen 0.0.0.0:14137 ssl;
    listen [::]:14137 ssl;

    server_name hsd-regtest.htools.work;
    ssl_certificate     /etc/letsencrypt/live/hsd-regtest.htools.work/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/hsd-regtest.htools.work/privkey.pem;

    location /custompath/ {
        #rewrite /custompath/(.*) /$1 break;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header HOST $http_host;
        proxy_pass http://127.0.0.1:14037/;
        proxy_redirect off;
    }
}

Will get back to this later, leaving the config and error here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remote RPC node connection over HTTPS is disabled
3 participants