Remove btcd cert shared volume (#486)

* Remove shared volume for btcd cert file

* Got ssl cert working as a config

* Remove old comment about adding ssl certificate in dockerfile
This commit is contained in:
Jonathan Zernik 2020-11-24 01:18:53 -05:00 committed by GitHub
parent c1e1f7c224
commit c62d4229cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 16 deletions

View file

@ -17,7 +17,6 @@ services:
- RPCHOST=bitcoin-core
- BACKEND=bitcoind
volumes:
- shared:/rpc
- ~/.lnd:/root/.lnd
ports:
- 9735:9735
@ -40,7 +39,6 @@ services:
- LOG_LEVEL
- SQUEAKNODE_SYNC_INTERVAL_S
volumes:
- shared:/rpc
- ~/.lnd:/root/.lnd
- ./config.ini:/app/config.ini
- ~/.sqk:/root/.sqk
@ -53,8 +51,3 @@ services:
sysctls:
- net.ipv6.conf.all.disable_ipv6=0
entrypoint: ["./start-squeaknode.sh"]
volumes:
# shared volume is needed for sharing the btcd certificate
shared:
driver: local

View file

@ -3,15 +3,6 @@
# exit from script if error was raised.
set -e
# Add btcd's RPC TLS certificate to system Certificate Authority list. exec runsqueak \
cp /rpc/rpc.cert /usr/share/ca-certificates/btcd.crt
echo btcd.crt >> /etc/ca-certificates.conf
update-ca-certificates
# To make python requests use the system ca-certificates bundle, it
# needs to be told to use it over its own embedded bundle
export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
# Wait for the lnd cert file to exist before starting
while ! test -f "/root/.lnd/tls.cert"; do
sleep 10

View file

@ -12,6 +12,7 @@ rpc_host=btcd
rpc_user=devuser
rpc_pass=devpass
rpc_use_ssl=true
rpc_ssl_cert=/rpc/rpc.cert
[postgresql]
host=db

View file

@ -1,3 +1,4 @@
import os
import json
import logging
from typing import Optional
@ -20,10 +21,16 @@ class BitcoinBlockchainClient(BlockchainClient):
rpc_user: str,
rpc_password: str,
use_ssl: bool,
ssl_cert: str,
) -> None:
protocol = "https" if use_ssl else "http"
self.url = f"{protocol}://{rpc_user}:{rpc_password}@{host}:{port}"
self.headers = {"content-type": "application/json"}
s = requests.Session()
if ssl_cert:
os.environ['SSL_CERT_FILE'] = ssl_cert
os.environ['REQUESTS_CA_BUNDLE'] = ssl_cert
s.cert = ssl_cert
def get_best_block_info(self) -> BlockInfo:
block_height = self.get_block_count()

View file

@ -45,6 +45,7 @@ class Config:
self._configs['bitcoin_rpc_user'] = self._get_bitcoin_rpc_user()
self._configs['bitcoin_rpc_pass'] = self._get_bitcoin_rpc_pass()
self._configs['bitcoin_rpc_use_ssl'] = self._get_bitcoin_rpc_use_ssl()
self._configs['bitcoin_rpc_ssl_cert'] = self._get_bitcoin_rpc_ssl_cert()
#lnd
self._configs['lnd_host'] = self._get_lnd_host()
@ -111,6 +112,9 @@ class Config:
def _get_bitcoin_rpc_use_ssl(self):
return self.parser.getboolean("bitcoin", "rpc_use_ssl", fallback=False)
def _get_bitcoin_rpc_ssl_cert(self):
return self.parser.get("bitcoin", "rpc_ssl_cert", fallback=None)
def _get_lnd_host(self):
return self.parser.get("lnd", "host")

View file

@ -120,6 +120,7 @@ def load_blockchain_client(config):
config.bitcoin_rpc_user,
config.bitcoin_rpc_pass,
config.bitcoin_rpc_use_ssl,
config.bitcoin_rpc_ssl_cert,
)