diff --git a/bin/telebit-remote.js b/bin/telebit-remote.js index 66f9cdd..29f25de 100755 --- a/bin/telebit-remote.js +++ b/bin/telebit-remote.js @@ -765,19 +765,23 @@ var keystore = require('../lib/keystore.js').create(state); var keyname = 'telebit-remote'; state.keystore = keystore; state.keystoreSecure = !keystore.insecure; -keystore.get(keyname).then(function (jwk) { - if (jwk && jwk.kty) { - state.key = jwk; +keystore.get(keyname).then(function (key) { + if (key && key.kty) { + state.key = key; fs.readFile(confpath, 'utf8', parseConfig); return; } - console.info('Generating Private Key...'); - return require('keypairs').generate().then(function (jwk) { + var keypairs = require('keypairs'); + return keypairs.generate().then(function (pair) { + var jwk = pair.private; return keystore.set(keyname, jwk).then(function () { - console.info("Generated New %s %s Private Key.", jwk.kty, (jwk.crv || Buffer.from(jwk.n, 'base64').byteLength * 8)); - state.key = jwk; - fs.readFile(confpath, 'utf8', parseConfig); + return keypairs.thumbprint({ jwk: pair.public }).then(function (kid) { + var size = (jwk.crv || Buffer.from(jwk.n, 'base64').byteLength * 8); + console.info("Generated new %s %s private key with thumbprint %s", jwk.kty, size, kid); + state.key = jwk; + fs.readFile(confpath, 'utf8', parseConfig); + }); }); }); });