bitpay / bitauth

Authenticate with web services utilizing the same strategy as Bitcoin.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Node 0.12.0 has 'bad decrypt' error

sheldonth opened this issue · comments

Attempting to use bitauth as part of the bitpay node.js module, and seeing

crypto.js:202
  var ret = this._handle.final();
                         ^
Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
    at Error (native)
    at Decipher.Cipher.final (crypto.js:202:26)
    at Object.decrypt (/home/.../node_modules/bitauth/lib/decrypt.js:7:23)
    at new Bitpay (/home/.../bitpay.js:53:27)

Has this been encountered yet? Was not having this problem on Node 0.10.33, seems new to 0.12.0

The offending code, in detail

keyPath = '/.bitpay/api.key' if not keyPath?
@encryptedPKey = (fs.readFileSync H + keyPath).toString()
@log.error "no bitpay private key present" if not @encryptedPKey?
@pKey = bitauth.decrypt '', @encryptedPKey
@client = bitpay.createClient @pKey

try:

keyPath = keyPath || '/.bitpay/api.key'