Code Monkey home page Code Monkey logo

Comments (13)

adshao avatar adshao commented on June 15, 2024 1

Hi,
从测试结果来看,可以定位为环境问题,两种可能:

  1. OSX Go的问题,在验证HTTPS证书时找的CA证书不对
  2. 环境CA证书有问题

对于OSX环境的这个错误,我只看到go源码的这个文件出现,如果想排查可以根据源码看看哪里有问题:https://github.com/golang/go/blob/release-branch.go1.9/src/crypto/x509/verify.go#L405
如果无法解决,也可以先用Insecure方式绕过,等部署到其他环境时再去掉。

from go-binance.

adshao avatar adshao commented on June 15, 2024

Hi @rafw ,
Could you give more info about this issue? the code snippet, output, etc.

from go-binance.

nifflin avatar nifflin commented on June 15, 2024

package main

import (
"github.com/adshao/go-binance"
"fmt"
"context"
)

func main() {
client := binance.NewClient("", "")
trades, err := client.NewAggTradesService().
Symbol("LTCBTC").StartTime(1508673256594).EndTime(1508673256595).
Do(context.Background())
if err != nil {
fmt.Println(err)
return
}
for _, t := range trades {
fmt.Println(t)
}
}

from go-binance.

nifflin avatar nifflin commented on June 15, 2024

Almost the same as your sample code. I removed access key and secret key in the demo.

Output:
Get https://www.binance.com/api/v1/aggTrades?endTime=1508673256595&startTime=1508673256594&symbol=LTCBTC: x509: certificate signed by unknown authority

from go-binance.

adshao avatar adshao commented on June 15, 2024

seems like a certificate issue on your server, can you try to update your ca bundle? if you are using CentOS, try this: sudo yum reinstall ca-certificates
I guess it is casued by the changing of binance ssl certificate recently.

from go-binance.

nifflin avatar nifflin commented on June 15, 2024

哎呀妈呀,我用的是macOs 10.11,同样的代码放在ubuntu上就对了。同样这个mac上,用chrome\firefox访问也能正确返回数据,连验证都不需要,直接输入https://www.binance.com/api/v1/aggTrades?symbol=NEOBTC就行了。

https://support.globalsign.com/customer/portal/articles/1353318-view-and-or-delete-crl-ocsp-cache
按此方法删除证书缓存是没有作用的。

tr := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, } client.HTTPClient.Transport = tr
这个方法可以绕过验证,但绕过安全验证不是好办法

golang/go#16589
andygrunwald/go-jira#52
https://github.com/hashicorp/go-rootcerts
这几个帖子感觉比较接近真相,但是不知道这个库怎么用于binance的https api。

究竟咋回事呢?老闹心了。

from go-binance.

adshao avatar adshao commented on June 15, 2024

请问你的Go版本是什么?根据你提供的几个链接,升级到Go1.9是否还存在这个问题?

from go-binance.

nifflin avatar nifflin commented on June 15, 2024

从1.7升级到1.9,还是一样的,按外国论坛的说法是因为mac 10.10、10.11导致的,升级操作系统可以解决。但是我不敢升级,现在升级是要到10.13.1了,不是稳定版

from go-binance.

adshao avatar adshao commented on June 15, 2024

我在OSX 10.12上没有遇到这个问题,看样子是跟本地环境有关。有几个方法可以确认是否是OSX上Go的问题:

  1. 本地执行curl https://www.binance.com/api/v1/aggTrades?endTime=1508673256595&startTime=1508673256594&symbol=LTCBTC 是否正常
  2. 本地使用Go访问其他https站点,或者使用另外的go binance SDK访问看看是否有同样的问题

from go-binance.

nifflin avatar nifflin commented on June 15, 2024

1、使用其他go binance库也有同样的报错
2、使用go的官方http库访问“https://www.binance.com/” 也有同样的报错
3、使用go的官方http库访问“https://www.baidu.com/” 一切正常
4、curl https://www.binance.com/api/v1/aggTrades?symbol=LTCBTC 一切正常

from go-binance.

nifflin avatar nifflin commented on June 15, 2024

嗯,等过段时间10.13稳定版出了,我升级后再试。程序最终也是linux、windows下跑,我更担心是mac不安全导致的。

from go-binance.

adshao avatar adshao commented on June 15, 2024

ok,如果解决了,麻烦告知解决办法。谢谢。

from go-binance.

nifflin avatar nifflin commented on June 15, 2024

升级到最新版本10.13.1,问题解决了 🆗

from go-binance.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.