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

Bit-z: SSL certificate verification failed (Python) #2459

Closed
wntsang4 opened this issue Apr 4, 2018 · 19 comments
Closed

Bit-z: SSL certificate verification failed (Python) #2459

wntsang4 opened this issue Apr 4, 2018 · 19 comments
Assignees

Comments

@wntsang4
Copy link

wntsang4 commented Apr 4, 2018

  • OS: Windows
  • Programming Language version: Python
  • CCXT version: 1.12.80
  • Exchange: Bit-Z
  • Method:

Request: GET https://www.bit-z.com/api_v1/tickerall {'User-Agent': 'python-requests/2.18.4', 'Accept-Encoding': 'gzip, deflate'} None

ExchangeError ("bitz https://www.bit-z.com/api_v1/tickerall GET HTTPSConnectionPool(host='www.bit-z.com', port=443): Max retries exceeded with url: /api_v1/tickerall (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)'),))",) Error

Is it the same problem?
#882

@kroitor
Copy link
Member

kroitor commented Apr 4, 2018

Yes, looks like it.

Most often this is caused by an outdated version of Anaconda Python, an update (including dependency packages) may be enough to resolve this.

@kroitor kroitor self-assigned this Apr 4, 2018
@wntsang4
Copy link
Author

wntsang4 commented Apr 4, 2018

I am using python 3.6.4.
I have tested it on a new machine with a new IP and got the same error.

@kroitor
Copy link
Member

kroitor commented Apr 4, 2018

@wntsang4 can you try reinstalling the dependencies with pip? Pay attention to any libssl versions you have installed... this problem is also frequently caused by outdated root CA files that come with your ssl lib.

@kroitor kroitor changed the title Bit-z: SSL verification error on Windows Bit-z: SSL certificate verification failed Apr 5, 2018
@wntsang4
Copy link
Author

wntsang4 commented Apr 5, 2018

aiodns (1.1.1)
aiohttp (3.1.1)
async-timeout (2.0.1)
attrs (17.4.0)
cchardet (2.1.1)
ccxt (1.12.87)
certifi (2018.1.18)
chardet (3.0.4)
idna (2.6)
idna-ssl (1.0.1)
multidict (4.1.0)
pip (9.0.3)
pycares (2.3.0)
requests (2.18.4)
setuptools (38.5.1)
urllib3 (1.22)
yarl (1.1.1)

I tried to reinstall all the dependencies with pip and got below response.

Request: GET https://www.bit-z.com/api_v1/tickerall {'User-Agent': 'python-requests/2.18.4', 'Accept-Encoding': 'gzip, deflate'} None

Response: GET https://www.bit-z.com/api_v1/tickerall 403 {'Date': 'Thu, 05 Apr 2018 16:03:50 GMT', 'Content-Type': 'text/html', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Vary': 'Accept-Encoding', 'X-Via-JSL': '65dea62,-', 'Set-Cookie': '__jsluid=15b89504a0297cad520942db470a0f88; max-age=31536000; path=/; HttpOnly', 'X-Cache': 'error', 'Content-Encoding': 'gzip'}

<style> body{ background:#fff; font-family: microsoft yahei; color:#969696; font-size:14px;} .online-desc-con { text-align:center; } .r-tip01 { color: #333; font-size: 18px; display: block; text-align: center; width: 500px; padding: 0 10px; overflow: hidden; text-overflow: ellipsis; margin: 0 auto 15px; } .r-tip02 { color: #585858; font-size: 14px; display: block; margin-top: 20px; margin-bottom: 20px; } #notice-jiasule { word-wrap: break-word; word-break: normal; color:#585858; border:1px solid #ddd; padding:0px 20px 0px 20px } img { border: 0; } .u-ico{ vertical-align: middle; margin-right: 12px;} .btn{ padding: 8px 22px; border-radius: 3px; border: 0; display: inline-block;vertical-align: middle;text-decoration: none;} .btn-g{ background-color: #61b25e; color: #fff;} .report {color: #858585; text-decoration: none;} .report:hover {text-decoration: underline; color: #0088CC;} hr{ border-top: 1px dashed #ddd;} center{ line-height: 48px; color: #919191;} </style> <script type="text/template" id="content_tpl"> <%= error_403 %>

�����<%- url %>

客�端���<%- user_agent %>

æ�¦æ�ªæ�¶é�´ï¼�<%- now %>  æ�¬æ¬¡äº�件ID <%- rule_id %>

å¦�æ��æ�¨æ�¯ç½�ç«�管ç��å��ï¼�请ç�»å½�ç�¥é��å��å®�äº�å®�å�¨  æ�¥ç��详æ��  æ��è��  å��é¦�误æ�¥ </script> <script type="text/javascript" src="/cdn-cgi/js/underscore_min_1.8.3.js"></script>

client: 3.17.160.9, server: 65dea62, time: 2018-04-06 00:03:50
<script> void(function fuckie6(){if(location.hash && /MSIE 6/.test(navigator.userAgent) && !/jsl_sec/.test(location.href)){location.href = location.href.split('#')[0] + '&jsl_sec' + location.hash}})(); var content = _.template(document.getElementById('content_tpl').innerHTML)({ error_403: '' || '��访��似�客���已被��管��设置为��', url: document.URL.replace(/\/g,"%3E"), user_agent: navigator.userAgent, now: new Date(new Date() - -8 * 3600000).toISOString().substr(0, 19).replace('T', ' '), rule_id: parseInt('[80001]'.replace(/\[|\]/g, '')) || '', from: encodeURIComponent(document.referrer.substr(0, 1024)), client_ip: '3.17.160.9', ref: encodeURIComponent(document.URL.substr(0, 1024)) }); document.getElementById('content_rendered').innerHTML = content; </script>
<script> var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://"); document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Fd7682ab43891c68a00de46e9ce5b76aa' type='text/javascript'%3E%3C/script%3E")); </script>

@kroitor
Copy link
Member

kroitor commented Apr 5, 2018

Is this URL https://www.bit-z.com/api_v1/tickerall available from the same machine in your browser?

@wntsang4
Copy link
Author

wntsang4 commented Apr 6, 2018

Yes. It works fine in browser.

@kroitor
Copy link
Member

kroitor commented Apr 6, 2018

@wntsang4 are you using the sync version or the async version?

@wntsang4
Copy link
Author

wntsang4 commented Apr 6, 2018

sync version

@kroitor
Copy link
Member

kroitor commented Apr 6, 2018

Ok, I'll spend some more time debugging it and will get back to you on this issue. This is most likely due to openssl installation that either comes with Anaconda Python or with a dependency... Do you know which version of OpenSSL you have, by the way?

@kroitor
Copy link
Member

kroitor commented Apr 6, 2018

@wntsang4 can you also try pip-uninstalling the certifi package to see if it does work normally without it, plz?

UPD. sorry, plz ignore it, it won't work like that without certifi and without changing the code...

@wntsang4
Copy link
Author

wntsang4 commented Apr 6, 2018

'OpenSSL 1.0.2k 26 Jan 2017'

After uninstalling the certifi package, it shows
ModuleNotFoundError: No module named 'certifi'

@kroitor
Copy link
Member

kroitor commented Apr 6, 2018

@wntsang4 oh... I'll update it to make certifi optional...

ContinuumIO/anaconda-issues#494

@kroitor
Copy link
Member

kroitor commented Apr 6, 2018

@wntsang4 can you plz show your instantiation code? (a snippet of code that you're using to reproduce it)

@wntsang4
Copy link
Author

wntsang4 commented Apr 6, 2018

bitz = ccxt.bitz({
'apiKey': key,
'secret': secret,
'enableRateLimit': True,
'verbose': True,
})

order_book = bitz.fetch_order_book('LTC/BTC', 3)

@kroitor kroitor changed the title Bit-z: SSL certificate verification failed Bit-z: SSL certificate verification failed Python Apr 6, 2018
@kroitor kroitor changed the title Bit-z: SSL certificate verification failed Python Bit-z: SSL certificate verification failed (Python) Apr 6, 2018
@kroitor
Copy link
Member

kroitor commented Apr 6, 2018

bitz = ccxt.bitz({
  'apiKey': key,
  'secret': secret,
  'enableRateLimit': True,
  'verbose': True,
  'userAgent': 'foobar',  # ←-------------------------- add this line (any random user-agent)
})

order_book = bitz.fetch_order_book('LTC/BTC', 3)

↑ Does it work this way? (need to install certifi back)

@wntsang4
Copy link
Author

wntsang4 commented Apr 6, 2018

It works!!

@kroitor
Copy link
Member

kroitor commented Apr 6, 2018

Yep, it's a python-specific problem, that is caused by transition to a new format of SSL certificates in the community... Apart from the above workaround we can't really do much about it, because it is far beyond our codebase (it's an issue with certifi + OpenSSL + python-requests), therefore some exchanges with older OpenSSL certificates will require the userAgent, which is very non-intuitive... Hope to resolve it soon. I would close it for now if you don't mind. Feel free to reopen it if needed or just ask questions if you have more.

https://www.google.ru/search?q=python+CERTIFICATE_VERIFY_FAILED+777

Thx for your feedback!

@kroitor kroitor closed this as completed Apr 6, 2018
@alexsith
Copy link

alexsith commented Apr 6, 2018

Hi. I just leave comment here. I had the same issue and I didn't do anything about this bug. I guess bitz did some upgrade and broke something. It had been happening for couple days if I correct remember and after that it's gone.

@kroitor
Copy link
Member

kroitor commented Apr 6, 2018

Thanks for your involvement, @alexsith !

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

3 participants