为什么coinbase api在代码正常工作时返回错误?

问题描述 投票:1回答:1

我正在使用上面的代码与coinbase api进行交互。它工作正常,但直到最近它返回一个错误。这是代码

var coinbase = require('coinbase');
var mysecret = 'apisecret'
var mykey = 'apikey'
var client   = new coinbase.Client({'apiKey': mykey, 'apiSecret': mysecret});
client.getAccounts({}, function(err, accounts) {
   if (err)throw err;
    console.log(accounts)

});

这是我得到的错误

if (err)throw err
           ^

Error: unable to get local issuer certificate
    at TLSSocket.onConnectSecure (_tls_wrap.js:1058:34)
    at TLSSocket.emit (events.js:198:13)
    at TLSSocket._finishInit (_tls_wrap.js:636:8)
node.js coinbase-api
1个回答
0
投票

Coinbase已更新SSL证书,为避免此问题,创建新客户端时需要将strictSSL设置为false

const coinbase = require('coinbase')

const mysecret = 'apisecret'
const mykey = 'apikey'

const client = new coinbase.Client({ apiKey: mykey, apiSecret: mysecret, strictSSL: false })

client.getAccounts({}, function(err, accounts) {
    if (err) throw err
    console.log(accounts)
})

或通过新证书

const coinbase = require('coinbase')

const mysecret = 'apisecret'
const mykey = 'apikey'
const caFile = fs.readFileSync('./caFileLocation')

const client = new coinbase.Client({ apiKey: mykey, apiSecret: mysecret, caFile })

client.getAccounts({}, function(err, accounts) {
    if (err) throw err
    console.log(accounts)
})
© www.soinside.com 2019 - 2024. All rights reserved.