Browse Source

fix(certs): fix issue with certs throwing SSL error

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
6c070e4592
  1. 5
      app/lnd/lib/lightning.js
  2. 28
      app/main.dev.js
  3. 9
      package.json
  4. 12
      resources/scripts/darwin_generate_certs.sh
  5. 11
      resources/scripts/linux_generate_certs.sh
  6. 11
      resources/scripts/win32_generate_certs.sh

5
app/lnd/lib/lightning.js

@ -4,11 +4,10 @@ import grpc from 'grpc'
import config from '../config'
module.exports = (rpcpath, host) => {
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA'
const rpc = grpc.load(path.join(__dirname, 'rpc.proto'))
const lndCert = fs.readFileSync(config.cert)
const credentials = grpc.credentials.createSsl(lndCert)
const rpc = grpc.load(path.join(__dirname, 'rpc.proto'))
return new rpc.lnrpc.Lightning(host, credentials)
}

28
app/main.dev.js

@ -111,7 +111,6 @@ app.on('ready', async () => {
// There was an error checking for the LND process
if (err) { throw new Error( err ) }
console.log('results: ', results)
// No LND process was found
if (!results.length) {
// Let the front end know we have started syncing LND
@ -132,13 +131,8 @@ app.on('ready', async () => {
break
}
// Check for certs to exists before we do things
certInterval = setInterval(() => {
if (fs.existsSync(certPath)) {
clearInterval(certInterval)
startLnd()
}
}, 500)
// Start LND
startLnd()
} else {
// An LND process was found, no need to start our own
console.log('LND ALREADY RUNNING')
@ -176,13 +170,25 @@ const startLnd = () => {
.on('error', error => console.log(`lnd error: ${error}`))
.on('close', code => console.log(`lnd shutting down ${code}`))
// Listen for when neutrino prints out data
neutrino.stdout.on('data', data => {
// Listen for when neutrino prints out data
neutrino.stdout.on('data', data => {
// Data stored in variable line, log line to the console
let line = data.toString('utf8')
if (process.env.NODE_ENV === 'development') { console.log(line) }
// If the gRPC proxy has started we can start ours
if (line.includes('gRPC proxy started')) {
certInterval = setInterval(() => {
if (fs.existsSync(certPath)) {
clearInterval(certInterval)
console.log('CERT EXISTS, STARTING GRPC')
startGrpc()
}
}, 1000)
}
// Pass current clock height progress to front end for loading state UX
if (line.includes('Caught up to height')) {
const blockHeight = line.slice(line.indexOf('Caught up to height') + 'Caught up to height'.length).trim()
@ -193,7 +199,7 @@ const startLnd = () => {
if (line.includes('Done catching up block hashes')) {
// Log that LND is caught up to the current block height
console.log('DONE CATCHING UP BLOCK HASHES')
startGrpc()
// Check for certs to exists before we do things
}
})
}

9
package.json

@ -37,8 +37,6 @@
"files": [
"dist/",
"resources/",
"resources/icons/wallet.svg",
"resources/icons/peers.svg",
"node_modules/",
"app.html",
"main.prod.js",
@ -74,12 +72,7 @@
"directories": {
"buildResources": "resources",
"output": "release"
},
"extraResources": [
"**/resources/bin/darwin/lnd",
"**/resources/scripts/darwin_generate_certs.sh",
"**/resources/icons/*"
]
}
},
"repository": {
"type": "git",

12
resources/scripts/darwin_generate_certs.sh

@ -1,12 +0,0 @@
# Generate Node.js compatible certs
# If Lnd folder doesn't exist we have to create it
if [ ! -d ~/Library/Application\ Support/Lnd ]; then
mkdir -p ~/Library/Application\ Support/Lnd;
fi
# Generate compatible certs
openssl ecparam -genkey -name prime256v1 -out ~/Library/Application\ Support/Lnd/tls.key
openssl req -new -sha256 -key ~/Library/Application\ Support/Lnd/tls.key -out ~/Library/Application\ Support/Lnd/csr.csr -subj '/CN=localhost/O=lnd'
openssl req -x509 -sha256 -days 3650 -key ~/Library/Application\ Support/Lnd/tls.key -in ~/Library/Application\ Support/Lnd/csr.csr -out ~/Library/Application\ Support/Lnd/tls.cert
rm ~/Library/Application\ Support/Lnd/csr.csr

11
resources/scripts/linux_generate_certs.sh

@ -1,11 +0,0 @@
# Generate Node.js compatible certs
# If Lnd folder doesn't exist we have to create it
if [ ! -d ~/Library/Application\ Support/Lnd ]; then
mkdir -p ~/.lnd;
fi
# Generate compatible certs
openssl ecparam -genkey -name prime256v1 -out ~/Library/Application\ Support/Lnd/tls.key
openssl req -new -sha256 -key ~/Library/Application\ Support/Lnd/tls.key -out ~/Library/Application\ Support/Lnd/csr.csr -subj '/CN=localhost/O=lnd'
openssl req -x509 -sha256 -days 3650 -key ~/Library/Application\ Support/Lnd/tls.key -in ~/Library/Application\ Support/Lnd/csr.csr -out ~/Library/Application\ Support/Lnd/tls.cert
rm ~/Library/Application\ Support/Lnd/csr.csr

11
resources/scripts/win32_generate_certs.sh

@ -1,11 +0,0 @@
# Generate Node.js compatible certs
# If Lnd folder doesn't exist we have to create it
if [ ! -d ~/Library/Application\ Support/Lnd ]; then
mkdir -p ~/AppData/Local/Lnd;
fi
# Generate compatible certs
openssl ecparam -genkey -name prime256v1 -out ~/Library/Application\ Support/Lnd/tls.key
openssl req -new -sha256 -key ~/Library/Application\ Support/Lnd/tls.key -out ~/Library/Application\ Support/Lnd/csr.csr -subj '/CN=localhost/O=lnd'
openssl req -x509 -sha256 -days 3650 -key ~/Library/Application\ Support/Lnd/tls.key -in ~/Library/Application\ Support/Lnd/csr.csr -out ~/Library/Application\ Support/Lnd/tls.cert
rm ~/Library/Application\ Support/Lnd/csr.csr
Loading…
Cancel
Save