Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x509: certificate signed by unknown authority #1

Closed
nifflin opened this issue Nov 4, 2017 · 13 comments
Closed

x509: certificate signed by unknown authority #1

nifflin opened this issue Nov 4, 2017 · 13 comments

Comments

@nifflin
Copy link

nifflin commented Nov 4, 2017

Error occurs in NewAggTradesService.

OS: mac os 10.11
Go: 1.9

@adshao
Copy link
Owner

adshao commented Nov 4, 2017

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

@nifflin
Copy link
Author

nifflin commented Nov 4, 2017

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

@nifflin
Copy link
Author

nifflin commented Nov 4, 2017

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

@adshao
Copy link
Owner

adshao commented Nov 4, 2017

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.

@nifflin
Copy link
Author

nifflin commented Nov 5, 2017

哎呀妈呀,我用的是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。

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

@adshao
Copy link
Owner

adshao commented Nov 6, 2017

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

@nifflin
Copy link
Author

nifflin commented Nov 6, 2017

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

@adshao
Copy link
Owner

adshao commented Nov 7, 2017

我在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访问看看是否有同样的问题

@nifflin
Copy link
Author

nifflin commented Nov 8, 2017

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 一切正常

@adshao
Copy link
Owner

adshao commented Nov 10, 2017

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方式绕过,等部署到其他环境时再去掉。

@nifflin
Copy link
Author

nifflin commented Nov 10, 2017

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

@adshao
Copy link
Owner

adshao commented Nov 10, 2017

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

@nifflin
Copy link
Author

nifflin commented Nov 12, 2017

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

@adshao adshao closed this as completed Nov 14, 2017
adshao pushed a commit that referenced this issue Mar 28, 2018
Streams the partial depth book websock. Tests pass. Client works in use.
wayne163 pushed a commit to wayne163/go-binance that referenced this issue Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants