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

why is coinbase api returning an error while the code was working fine?

我使用上面的代码与 coinbase 进行交互 api.it 工作正常,但直到最近它 returns error.Here 是代码

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)

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)
})