BitBotFactory / MikaLendingBot

Automated lending on Cryptocurrency exchanges Poloniex and Bitfinex
http://poloniexlendingbot.readthedocs.io/en/latest/index.html
MIT License
1.11k stars 344 forks source link

SSL: CERTIFICATE_VERIFY_FAILED #95

Closed OneArb closed 7 years ago

OneArb commented 8 years ago

Hello,

I must be overlooking something obvious !

I used notepad++ to edit default.cfg

I copy pasted apikey and secret from Poloniex, I get the following messages:

Thanks

cmd output ---

Obtaining settings from config file.
Welcome to Poloniex Lending Bot
2016-08-01 17:04:14 ERROR: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)>
Traceback (most recent call last):
  File "R:\poloniexlendingbot-master\lendingbot.py", line 460, in <module>
    refreshTotalLended()
  File "R:\poloniexlendingbot-master\lendingbot.py", line 223, in refreshTotalLended
    cryptoLended = bot.returnActiveLoans()
  File "R:\poloniexlendingbot-master\poloniex.py", line 101, in returnActiveLoans
    return self.api_query('returnActiveLoans')
  File "R:\poloniexlendingbot-master\poloniex.py", line 58, in api_query
    ret = urllib2.urlopen(urllib2.Request('https://poloniex.com/tradingApi', post_data, headers))
  File "C:\Program\Python27\lib\urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Program\Python27\lib\urllib2.py", line 431, in open
    response = self._open(req, data)
  File "C:\Program\Python27\lib\urllib2.py", line 449, in _open
    '_open', req)
  File "C:\Program\Python27\lib\urllib2.py", line 409, in _call_chain
    result = func(_args)
  File "C:\Program\Python27\lib\urllib2.py", line 1240, in https_open
    context=self._context)
  File "C:\Program\Python27\lib\urllib2.py", line 1197, in do_open
    raise URLError(err)
URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)>
2016-08-01 17:05:14 ERROR: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)>
Traceback (most recent call last):
  File "R:\poloniexlendingbot-master\lendingbot.py", line 460, in <module>
    refreshTotalLended()
  File "R:\poloniexlendingbot-master\lendingbot.py", line 223, in refreshTotalLended
    cryptoLended = bot.returnActiveLoans()
  File "R:\poloniexlendingbot-master\poloniex.py", line 101, in returnActiveLoans
    return self.api_query('returnActiveLoans')
  File "R:\poloniexlendingbot-master\poloniex.py", line 58, in api_query
    ret = urllib2.urlopen(urllib2.Request('https://poloniex.com/tradingApi', post_data, headers))
  File "C:\Program\Python27\lib\urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Program\Python27\lib\urllib2.py", line 431, in open
    response = self._open(req, data)
  File "C:\Program\Python27\lib\urllib2.py", line 449, in _open
    '_open', req)
  File "C:\Program\Python27\lib\urllib2.py", line 409, in _call_chain
    result = func(_args)
  File "C:\Program\Python27\lib\urllib2.py", line 1240, in https_open
    context=self._context)
  File "C:\Program\Python27\lib\urllib2.py", line 1197, in do_open
    raise URLError(err)
URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)>
2016-08-01 17:06:14 ERROR: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)>
Traceback (most recent call last):
  File "R:\poloniexlendingbot-master\lendingbot.py", line 460, in <module>
    refreshTotalLended()
  File "R:\poloniexlendingbot-master\lendingbot.py", line 223, in refreshTotalLended
    cryptoLended = bot.returnActiveLoans()
  File "R:\poloniexlendingbot-master\poloniex.py", line 101, in returnActiveLoans
    return self.api_query('returnActiveLoans')
  File "R:\poloniexlendingbot-master\poloniex.py", line 58, in api_query
    ret = urllib2.urlopen(urllib2.Request('https://poloniex.com/tradingApi', post_data, headers))
  File "C:\Program\Python27\lib\urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Program\Python27\lib\urllib2.py", line 431, in open
    response = self._open(req, data)
  File "C:\Program\Python27\lib\urllib2.py", line 449, in _open
    '_open', req)
  File "C:\Program\Python27\lib\urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "C:\Program\Python27\lib\urllib2.py", line 1240, in https_open
    context=self._context)
  File "C:\Program\Python27\lib\urllib2.py", line 1197, in do_open
    raise URLError(err)
URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)>
2016-08-01 17:07:04 bye

[API]
apikey = myapikey
secret = thesecret

[BOT]
# sleep between active iterations, time in seconds (1-3600)

sleeptimeactive = 60
# sleep between inactive iterations, time in seconds (1-3600)
# set to same as sleeptimeactive to disable

sleeptimeinactive = 300
# minimum daily lend rate in percent (0.00003-0.05)

mindailyrate = 0.04
# max rate. 2% is good choice because it's default at margin trader interface.
#5% is max to be accepted by the exchange (0.00003-0.05)

maxdailyrate = 2
# The number of offers to split the available balance across the [gaptop, gapbottom] range. (1-20)

spreadlend = 3
# The depth of lendbook (in percent of lendable balance) to move through
# before placing the first (gapbottom) and last (gaptop) offer.
# If gapbottom is set to 0, the first offer will be at the lowest possible rate.
# However some low value is recommended (say 10%) to skip dust offers.

gapbottom = 10
gaptop = 200
# Daily lend rate threshold after which we offer lends for 60 days as opposed to 2.
# If set to 0 all offers will be placed for a 2 day period (0.00003-0.05)

sixtydaythreshold = 0.2
# Minimum loan size the minimum size of offers to make, bigger values prevent the bot from loaning small available amounts but reduce loans fragmentation

minloansize = 0.001
# AutoRenew - if set to 1 the bot will set the AutoRenew flag for the loans when you stop it (Ctrl+C) and clear the AutoRenew flag when on started

autorenew = 0
# custom config per coin, useful when closing positions etc.
# syntax: ["COIN:mindailyrate:maxactiveamount",...]
# if maxactive amount is 0 - stop lending this coin. in the future you'll be able to limit amount to be lent.
# coinconfig = ["BTC:0.18:1","CLAM:0.6:1"]
# this option creates a json log file instead of console output which includes the most recent status
# uncomment both jsonfile and jsonlogsize to enable
# jsonfile = www/botlog.json
# limits the amount of log lines to save
# jsonlogsize = 200
# enables a webserver for the www folder, in order to easily use the lendingbot.html with the json log
# startWebServer = true
rnevet commented 8 years ago

Did you manage to solve the issue?

I actually didn't see this behavior before - but the error log says URLError - could be proxy related? ssl issues (is your computer time correct?)

Where does this actually appear "SSL: CERTIFICATE_VERIFY_FAILED" ?

OneArb commented 8 years ago

I synchronize with an NTP server and do not use a proxy. I am able to pull a quote request.

[SSL: CERTIFICATE_VERIFY_FAILED] comes up on the very few first lines of the Windows command console :

Obtaining settings from config file. Welcome to Poloniex Lending Bot 2016-08-04 18:53:22 ERROR: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certi ficate verify failed (_ssl.c:590)>

The issue seems quite similar to

https://stackoverflow.com/questions/25981703/pip-install-fails-with-connection-error-ssl-certificate-verify-failed-certi?rq=1

I have installed pip.exe using get-pip.py

pip runs but does nothing not even pip freeze

The target seems to install --trusted-host

Using easy_install whell_package_name.whl I get

error: couldn't find setup script

I opened an issue with github pip.

Any idea on how to install --trusted-host using easy_install ?

The road to riches are paved with patience !

Thanks

OneArb commented 8 years ago

I think I was able to install --trusted-host I found in the rds-host package.

I don't know to verify --trusted-host is installed although I can verify rds-host is.

So far I get the same SSL: CERTIFICATE_VERIFY_FAILED

Any idea how to check --trusted-host is installed ?

Thanks

rnevet commented 8 years ago

@OneArb did you solve the issue? can you update and close it?

OneArb commented 8 years ago

I am not sure I am doing this right.

Does apikey and secret expect a quoted string a single-quote ?

rnevet commented 8 years ago

No quotes.

rnevet commented 8 years ago

Issue solved? (BTW, the latest update should give you better error indication.)

OneArb commented 8 years ago

Thanks for keeping up with it! This what I get.

I also get several errors running \Python27\Lib\test\test_ssl.py.

Obtaining settings from config file.
Welcome to Poloniex Lending Bot
2016-08-28 00:07:55 ERROR: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)>
2016-08-28 00:07:55
Traceback (most recent call last):
  File "lendingbot.py", line 456, in <module>
    refreshTotalLended()
  File "lendingbot.py", line 223, in refreshTotalLended
    cryptoLended = bot.returnActiveLoans()
  File "R:\poloniex.py", line 110, in returnActiveLoans
    return self.api_query('returnActiveLoans')
  File "R:\poloniex.py", line 67, in api_query
    ret = urllib2.urlopen(urllib2.Request('https://poloniex.com/tradingApi', post_data, headers))
  File "C:\Program\Python27\lib\urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Program\Python27\lib\urllib2.py", line 431, in open
    response = self._open(req, data)
  File "C:\Program\Python27\lib\urllib2.py", line 449, in _open
    '_open', req)
  File "C:\Program\Python27\lib\urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "C:\Program\Python27\lib\urllib2.py", line 1240, in https_open
    context=self._context)
  File "C:\Program\Python27\lib\urllib2.py", line 1197, in do_open
    raise URLError(err)
URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)>

Running \Python27\Lib\test\test_ssl.py

 server:  new connection from ('127.0.0.1', 22978)
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 server: selected protocol is now None
ok
test_compression (**main**.ThreadedTests) ...  server:  new connection from ('127.0.0.1', 22981)
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 client:  sending 'FOO\n'...
 server: selected protocol is now None
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  closing connection.
 got compression: None
ok
test_compression_disabled (**main**.ThreadedTests) ...  server:  new connection from ('127.0.0.1', 22983)
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 client:  sending 'FOO\n'...
 server: selected protocol is now None
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  closing connection.
ok
test_crl_check (**main**.ThreadedTests) ...
 server:  new connection from ('127.0.0.1', 22985)
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 server: selected protocol is now None
 server:  new connection from ('127.0.0.1', 22987)

 server:  bad connection attempt from ('127.0.0.1', 22987):
Traceback (most recent call last):
   File "C:\Program\Python27\Lib\test\test_ssl.py", line 1572, in wrap_conn
    self.sock, server_side=True)
   File "C:\Program\Python27\lib\ssl.py", line 352, in wrap_socket
    _context=self)
   File "C:\Program\Python27\lib\ssl.py", line 579, in __init__
    self.do_handshake()
   File "C:\Program\Python27\lib\ssl.py", line 808, in do_handshake
    self._sslobj.do_handshake()
 error: [Errno 10054] An existing connection was forcibly closed by the remote host
 server:  new connection from ('127.0.0.1', 22989)
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 server: selected protocol is now None
ok
test_default_ciphers (__main__.ThreadedTests) ... ok
test_default_ecdh_curve (**main**.ThreadedTests) ...  server:  new connection from ('127.0.0.1', 22993)
 server: connection cipher is now ('ECDHE-RSA-AES256-GCM-SHA384', 'TLSv1/SSLv3', 256)
 server: selected protocol is now None
ok
test_dh_params (**main**.ThreadedTests) ...  server:  new connection from ('127.0.0.1', 22995)
 server: connection cipher is now ('DHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 client:  sending 'FOO\n'...
 server: selected protocol is now None
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  closing connection.
ok
test_do_handshake_enotconn (**main**.ThreadedTests) ... ok
test_echo (**main**.ThreadedTests)
Basic test of an SSL client connecting to a server ...
 server:  new connection from ('127.0.0.1', 22997)
 client:  sending 'FOO\n'...
 server: connection cipher is now ('RC2-CBC-MD5', 'SSLv2', 128)
 server: selected protocol is now None
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  closing connection.
 server:  new connection from ('127.0.0.1', 22999)
 client:  sending 'FOO\n'...
 server: connection cipher is now ('AES256-SHA', 'TLSv1/SSLv3', 256)
 server: selected protocol is now None
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  closing connection.
 server:  new connection from ('127.0.0.1', 23001)
 server: connection cipher is now ('ECDHE-RSA-AES256-GCM-SHA384', 'TLSv1/SSLv3', 256)
 server: selected protocol is now None
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  closing connection.
 server:  new connection from ('127.0.0.1', 23003)
 client:  sending 'FOO\n'...
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 server: selected protocol is now None
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  closing connection.
 server:  new connection from ('127.0.0.1', 23005)
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 client:  sending 'FOO\n'...
 server: selected protocol is now None
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  closing connection.
 server:  new connection from ('127.0.0.1', 23007)
 client:  sending 'FOO\n'...
 server: connection cipher is now ('ECDHE-RSA-AES256-GCM-SHA384', 'TLSv1/SSLv3', 256)
 server: selected protocol is now None
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  closing connection.
ok
test_empty_cert (**main**.ThreadedTests)
Connecting with an empty cert file ...
SSLError is [SSL] PEM lib (_ssl.c:2580)
ok
test_getpeercert (__main__.ThreadedTests) ...
{'issuer': ((('countryName', u'XY'),),
            (('localityName', u'Castle Anthrax'),),
            (('organizationName', u'Python Software Foundation'),),
            (('commonName', u'localhost'),)),
 'notAfter': 'Oct  5 23:01:56 2020 GMT',
 'notBefore': u'Oct  8 23:01:56 2010 GMT',
 'serialNumber': u'D7C7381919AFC24E',
 'subject': ((('countryName', u'XY'),),
             (('localityName', u'Castle Anthrax'),),
             (('organizationName', u'Python Software Foundation'),),
             (('commonName', u'localhost'),)),
 'subjectAltName': (('DNS', 'localhost'),),
 'version': 3L}
Connection cipher is ('ECDHE-RSA-AES256-GCM-SHA384', 'TLSv1/SSLv3', 256).
ok
test_getpeercert_enotconn (**main**.ThreadedTests) ... ok
test_handshake_timeout (**main**.ThreadedTests) ... ok
test_malformed_cert (**main**.ThreadedTests)
Connecting with a badly formatted certificate (syntax error) ...
SSLError is [SSL] PEM lib (_ssl.c:2580)
ok
test_malformed_key (__main__.ThreadedTests)
Connecting with a badly formatted key (syntax error) ...
SSLError is [SSL] PEM lib (_ssl.c:2580)
ok
test_nonexisting_cert (__main__.ThreadedTests)
Connecting with a non-existing cert file ...
SSLError is [SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:590)
ok
test_npn_protocols (__main__.ThreadedTests) ...  server:  new connection from ('127.0.0.1', 23019)
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 server: selected protocol is now http/1.1
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  closing connection.
 server:  new connection from ('127.0.0.1', 23021)
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 client:  sending 'FOO\n'...
 server: selected protocol is now http/1.1
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  closing connection.
 server:  new connection from ('127.0.0.1', 23023)
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 client:  sending 'FOO\n'...
 server: selected protocol is now spdy/2
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  closing connection.
 server:  new connection from ('127.0.0.1', 23025)
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 client:  sending 'FOO\n'...
 server: selected protocol is now abc
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  closing connection.
ok
test_protocol_sslv2 (**main**.ThreadedTests)
Connecting to an SSLv2 server with various client options ...
 PROTOCOL_SSLv2->PROTOCOL_SSLv2 CERT_NONE
 PROTOCOL_SSLv2->PROTOCOL_SSLv2 CERT_OPTIONAL
 PROTOCOL_SSLv2->PROTOCOL_SSLv2 CERT_REQUIRED
 {PROTOCOL_SSLv23->PROTOCOL_SSLv2} CERT_NONE
 {PROTOCOL_SSLv3->PROTOCOL_SSLv2} CERT_NONE
 {PROTOCOL_TLSv1->PROTOCOL_SSLv2} CERT_NONE
 {PROTOCOL_SSLv23->PROTOCOL_SSLv2} CERT_NONE
 {PROTOCOL_SSLv23->PROTOCOL_SSLv2} CERT_NONE
 {PROTOCOL_SSLv23->PROTOCOL_SSLv2} CERT_NONE
ok
test_protocol_sslv23 (**main**.ThreadedTests)
Connecting to an SSLv23 server with various client options ...
 PROTOCOL_SSLv2->PROTOCOL_SSLv23 CERT_NONE
 SSL2 client to SSL23 server test unexpectedly failed:
 [Errno 10054] An existing connection was forcibly closed by the remote host
 PROTOCOL_SSLv3->PROTOCOL_SSLv23 CERT_NONE
 PROTOCOL_SSLv23->PROTOCOL_SSLv23 CERT_NONE
 PROTOCOL_TLSv1->PROTOCOL_SSLv23 CERT_NONE
 PROTOCOL_SSLv3->PROTOCOL_SSLv23 CERT_OPTIONAL
 PROTOCOL_SSLv23->PROTOCOL_SSLv23 CERT_OPTIONAL
 PROTOCOL_TLSv1->PROTOCOL_SSLv23 CERT_OPTIONAL
 PROTOCOL_SSLv3->PROTOCOL_SSLv23 CERT_REQUIRED
 PROTOCOL_SSLv23->PROTOCOL_SSLv23 CERT_REQUIRED
 PROTOCOL_TLSv1->PROTOCOL_SSLv23 CERT_REQUIRED
 {PROTOCOL_SSLv3->PROTOCOL_SSLv23} CERT_NONE
 PROTOCOL_SSLv23->PROTOCOL_SSLv23 CERT_NONE
 {PROTOCOL_TLSv1->PROTOCOL_SSLv23} CERT_NONE
ok
test_protocol_sslv3 (**main**.ThreadedTests)
Connecting to an SSLv3 server with various client options ...
 PROTOCOL_SSLv3->PROTOCOL_SSLv3 CERT_NONE
 PROTOCOL_SSLv3->PROTOCOL_SSLv3 CERT_OPTIONAL
 PROTOCOL_SSLv3->PROTOCOL_SSLv3 CERT_REQUIRED
 {PROTOCOL_SSLv2->PROTOCOL_SSLv3} CERT_NONE
 {PROTOCOL_SSLv23->PROTOCOL_SSLv3} CERT_NONE
 {PROTOCOL_TLSv1->PROTOCOL_SSLv3} CERT_NONE
 PROTOCOL_SSLv23->PROTOCOL_SSLv3 CERT_NONE
ok
test_protocol_tlsv1 (**main**.ThreadedTests)
Connecting to a TLSv1 server with various client options ...
 PROTOCOL_TLSv1->PROTOCOL_TLSv1 CERT_NONE
 PROTOCOL_TLSv1->PROTOCOL_TLSv1 CERT_OPTIONAL
 PROTOCOL_TLSv1->PROTOCOL_TLSv1 CERT_REQUIRED
 {PROTOCOL_SSLv2->PROTOCOL_TLSv1} CERT_NONE
 {PROTOCOL_SSLv3->PROTOCOL_TLSv1} CERT_NONE
 {PROTOCOL_SSLv23->PROTOCOL_TLSv1} CERT_NONE
ok
test_protocol_tlsv1_1 (**main**.ThreadedTests)
Connecting to a TLSv1.1 server with various client options. ...
 PROTOCOL_TLSv1_1->PROTOCOL_TLSv1_1 CERT_NONE
 {PROTOCOL_SSLv2->PROTOCOL_TLSv1_1} CERT_NONE
 {PROTOCOL_SSLv3->PROTOCOL_TLSv1_1} CERT_NONE
 {PROTOCOL_SSLv23->PROTOCOL_TLSv1_1} CERT_NONE
 PROTOCOL_TLSv1_1->PROTOCOL_SSLv23 CERT_NONE
 {PROTOCOL_TLSv1->PROTOCOL_TLSv1_1} CERT_NONE
 {PROTOCOL_TLSv1_1->PROTOCOL_TLSv1} CERT_NONE
ok
test_protocol_tlsv1_2 (**main**.ThreadedTests)
Connecting to a TLSv1.2 server with various client options. ...
 PROTOCOL_TLSv1_2->PROTOCOL_TLSv1_2 CERT_NONE
 {PROTOCOL_SSLv2->PROTOCOL_TLSv1_2} CERT_NONE
 {PROTOCOL_SSLv3->PROTOCOL_TLSv1_2} CERT_NONE
 {PROTOCOL_SSLv23->PROTOCOL_TLSv1_2} CERT_NONE
 PROTOCOL_TLSv1_2->PROTOCOL_SSLv23 CERT_NONE
 {PROTOCOL_TLSv1->PROTOCOL_TLSv1_2} CERT_NONE
 {PROTOCOL_TLSv1_2->PROTOCOL_TLSv1} CERT_NONE
 {PROTOCOL_TLSv1_1->PROTOCOL_TLSv1_2} CERT_NONE
 {PROTOCOL_TLSv1_2->PROTOCOL_TLSv1_1} CERT_NONE
ok
test_read_write_after_close_raises_valuerror (**main**.ThreadedTests) ... ok
test_recv_send (**main**.ThreadedTests)
Test recv(), send() and friends. ...
 server:  new connection from ('127.0.0.1', 23131)
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 server: selected protocol is now None
ok
test_rude_shutdown (**main**.ThreadedTests)
A brutal shutdown of an SSL server should raise an OSError ... ok
test_selected_alpn_protocol (**main**.ThreadedTests) ...  server:  new connection from ('127.0.0.1', 23135)
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 client:  sending 'FOO\n'...
 server: selected protocol is now None
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  closing connection.
ok
test_selected_alpn_protocol_if_server_uses_alpn (**main**.ThreadedTests) ...  server:  new connection from
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 client:  sending 'FOO\n'...
 server: selected protocol is now None
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  closing connection.
ok
test_selected_npn_protocol (**main**.ThreadedTests) ...  server:  new connection from ('127.0.0.1', 23139)
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 client:  sending 'FOO\n'...
 server: selected protocol is now None
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  sending 'FOO\n'...
 client:  read 'foo\n'
 client:  closing connection.
ok
test_server_accept (**main**.ThreadedTests) ... ok
test_sni_callback (**main**.ThreadedTests) ...  server:  new connection from ('127.0.0.1', 23143)
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 server: selected protocol is now None
 server:  new connection from ('127.0.0.1', 23145)
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 server: selected protocol is now None
 server:  new connection from ('127.0.0.1', 23147)
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 server: selected protocol is now None
ok
test_sni_callback_alert (**main**.ThreadedTests) ... ok
test_sni_callback_raising (**main**.ThreadedTests) ... ok
test_sni_callback_wrong_return_type (**main**.ThreadedTests) ... ok
test_socketserver (**main**.ThreadedTests)
Using a SocketServer to create and manage SSL connections. ...
 server (('127.0.0.1', 23154):23154 ('ECDHE-RSA-AES256-GCM-SHA384', 'TLSv1/SSLv3', 256)):
   [28/Aug/2016 00:20:42] "GET /keycert.pem HTTP/1.1" 200 -
 client: read 1783 bytes from remote server '<HTTPSServerThread <HTTPSServer localhost:23154>>'
stopping HTTPS server
joining HTTPS thread
ok
test_starttls (**main**.ThreadedTests)
Switching from clear text to encrypted and back again. ...
 client:  sending 'msg 1'...
 server:  new connection from ('127.0.0.1', 23157)
 server: read 'msg 1' (unencrypted), sending back 'msg 1' (unencrypted)...
 client:  read 'msg 1' from server
 client:  sending 'MSG 2'...
 server: read 'MSG 2' (unencrypted), sending back 'msg 2' (unencrypted)...
 client:  read 'msg 2' from server
 client:  sending 'STARTTLS'...
 server: read STARTTLS from client, sending OK...
 client:  read 'ok' from server, starting TLS...
 client:  sending 'MSG 3'...
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 server: selected protocol is now None
 server: read 'MSG 3' (encrypted), sending back 'msg 3' (encrypted)...
 client:  read 'msg 3' from server
 client:  sending 'msg 4'...
 server: read 'msg 4' (encrypted), sending back 'msg 4' (encrypted)...
 client:  read 'msg 4' from server
 client:  sending 'ENDTLS'...
 server: read ENDTLS from client, sending OK...
 client:  read 'ok' from server, ending TLS...
 client:  sending 'msg 5'...
 server: connection is now unencrypted...
 server: read 'msg 5' (unencrypted), sending back 'msg 5' (unencrypted)...
 client:  read 'msg 5' from server
 client:  sending 'msg 6'...
 server: read 'msg 6' (unencrypted), sending back 'msg 6' (unencrypted)...
 client:  read 'msg 6' from server
 client:  closing connection.
 server: client closed connection
ok
test_tls_unique_channel_binding (**main**.ThreadedTests)
Test tls-unique channel binding. ...
 server:  new connection from ('127.0.0.1', 23159)
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 got channel binding data: 'V\xe1K\x01\xe6\x8ag\xbc\xd2\x88^\xa1'
 server: selected protocol is now None
 server:  new connection from ('127.0.0.1', 23160)
 server: connection cipher is now ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
 got another channel binding data: '\xab\x17\xd5\x0b\x83\xc0Y\x96v\xfb\x04\xb4'
 server: selected protocol is now None
ok
test_version_basic (**main**.ThreadedTests) ... ok

## ERROR: test_connect (**main**.NetworkedTests)

Traceback (most recent call last):
  File "C:\Program\Python27\Lib\test\test_ssl.py", line 1239, in test_connect
    s.connect(("svn.python.org", 443))
  File "C:\Program\Python27\lib\ssl.py", line 844, in connect
    self._real_connect(addr, False)
  File "C:\Program\Python27\lib\ssl.py", line 835, in _real_connect
    self.do_handshake()
  File "C:\Program\Python27\lib\ssl.py", line 808, in do_handshake
    self._sslobj.do_handshake()
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)

# 

## ERROR: test_connect_cadata (**main**.NetworkedTests)

Traceback (most recent call last):
  File "C:\Program\Python27\Lib\test\test_ssl.py", line 1384, in test_connect_cadata
    s.connect(("svn.python.org", 443))
  File "C:\Program\Python27\lib\ssl.py", line 844, in connect
    self._real_connect(addr, False)
  File "C:\Program\Python27\lib\ssl.py", line 835, in _real_connect
    self.do_handshake()
  File "C:\Program\Python27\lib\ssl.py", line 808, in do_handshake
    self._sslobj.do_handshake()
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)

# 

## ERROR: test_connect_capath (**main**.NetworkedTests)

Traceback (most recent call last):
  File "C:\Program\Python27\Lib\test\test_ssl.py", line 1357, in test_connect_capath
    s.connect(("svn.python.org", 443))
  File "C:\Program\Python27\lib\ssl.py", line 844, in connect
    self._real_connect(addr, False)
  File "C:\Program\Python27\lib\ssl.py", line 835, in _real_connect
    self.do_handshake()
  File "C:\Program\Python27\lib\ssl.py", line 808, in do_handshake
    self._sslobj.do_handshake()
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)

# 

## ERROR: test_connect_ex (**main**.NetworkedTests)

Traceback (most recent call last):
  File "C:\Program\Python27\Lib\test\test_ssl.py", line 1251, in test_connect_ex
    self.assertEqual(0, s.connect_ex(("svn.python.org", 443)))
  File "C:\Program\Python27\lib\ssl.py", line 849, in connect_ex
    return self._real_connect(addr, True)
  File "C:\Program\Python27\lib\ssl.py", line 835, in _real_connect
    self.do_handshake()
  File "C:\Program\Python27\lib\ssl.py", line 808, in do_handshake
    self._sslobj.do_handshake()
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)

# 

## ERROR: test_connect_with_context (**main**.NetworkedTests)

Traceback (most recent call last):
  File "C:\Program\Python27\Lib\test\test_ssl.py", line 1339, in test_connect_with_context
    s.connect(("svn.python.org", 443))
  File "C:\Program\Python27\lib\ssl.py", line 844, in connect
    self._real_connect(addr, False)
  File "C:\Program\Python27\lib\ssl.py", line 835, in _real_connect
    self.do_handshake()
  File "C:\Program\Python27\lib\ssl.py", line 808, in do_handshake
    self._sslobj.do_handshake()
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)

# 

## ERROR: test_get_ca_certs_capath (**main**.NetworkedTests)

Traceback (most recent call last):
  File "C:\Program\Python27\Lib\test\test_ssl.py", line 1519, in test_get_ca_certs_capath
    s.connect(("svn.python.org", 443))
  File "C:\Program\Python27\lib\ssl.py", line 844, in connect
    self._real_connect(addr, False)
  File "C:\Program\Python27\lib\ssl.py", line 835, in _real_connect
    self.do_handshake()
  File "C:\Program\Python27\lib\ssl.py", line 808, in do_handshake
    self._sslobj.do_handshake()
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)

# 

## ERROR: test_get_server_certificate (**main**.NetworkedTests)

Traceback (most recent call last):
  File "C:\Program\Python27\Lib\test\test_ssl.py", line 1463, in test_get_server_certificate
    _test_get_server_certificate('svn.python.org', 443, SVN_PYTHON_ORG_ROOT_CERT)
  File "C:\Program\Python27\Lib\test\test_ssl.py", line 1457, in _test_get_server_certificate
    ca_certs=cert)
  File "C:\Program\Python27\lib\ssl.py", line 985, in get_server_certificate
    with closing(context.wrap_socket(sock)) as sslsock:
  File "C:\Program\Python27\lib\ssl.py", line 352, in wrap_socket
    _context=self)
  File "C:\Program\Python27\lib\ssl.py", line 579, in __init__
    self.do_handshake()
  File "C:\Program\Python27\lib\ssl.py", line 808, in do_handshake
    self._sslobj.do_handshake()
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)

# 

## ERROR: test_non_blocking_connect_ex (**main**.NetworkedTests)

Traceback (most recent call last):
  File "C:\Program\Python27\Lib\test\test_ssl.py", line 1274, in test_non_blocking_connect_ex
    s.do_handshake()
  File "C:\Program\Python27\lib\ssl.py", line 808, in do_handshake
    self._sslobj.do_handshake()
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)

---

Ran 105 tests in 22.843s

FAILED (errors=8, skipped=4)
Traceback (most recent call last):
  File "C:\Program\Python27\Lib\test\test_ssl.py", line 3053, in <module>
    test_main()
  File "C:\Program\Python27\Lib\test\test_ssl.py", line 3047, in test_main
    support.run_unittest(*tests)
  File "C:\Program\Python27\lib\test\test_support.py", line 1400, in run_unittest
    _run_suite(suite)
  File "C:\Program\Python27\lib\test\test_support.py", line 1383, in _run_suite
    raise TestFailed(err)
test.test_support.TestFailed: multiple errors occurred
rnevet commented 8 years ago

Did you check that the time/zone is configured correctly on your machine?

OneArb commented 8 years ago

I double-checked the Time Zone setting. I synchronized my computer with a NTP server and the computer clock provides the correct time.

test_ssl.py still comes up with errors.

poloniex.py reports the exact same messages.

magalhaesneto commented 8 years ago

I just got the same issue here: urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)

rnevet commented 8 years ago

Which Python version are you using?

magalhaesneto commented 8 years ago

Version 2.7.10 (2.7.10) Python 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12)

OneArb commented 8 years ago

Using same version:

Python 2.7.10 (default, May 23 2015, 09:40:32)

Since I failed running test_ssl.py I looked around and found the following:

https://pypi.python.org/pypi/six Python 2 and 3 compatibility utilities

That was used it seems to get a modified version of test_ssl.py to run https://github.com/gwik/geventhttpclient/blob/master/src/geventhttpclient/tests/test_ssl.py

Are those files likely to bring us closer to the solution?

dking7334 commented 7 years ago

So I run Mac OS 10.12 and was having this same problem. I did get it fixed by editing the "poloniex.py" file to the follow:

`# coding=utf-8 import hashlib import hmac import json import socket import time import urllib import urllib2 import ssl

ssl._create_default_https_context = ssl._create_unverified_context

class PoloniexApiError(Exception): pass ` This does bypass the SSL certificate verification so I would treat it more as a work around then an actual resolution; I don't believe it should be a problem as long as you have your API configured correctly but I'm not sure so of course do your own research but hope this helps everyone.

Evanito commented 7 years ago

ssl._create_default_https_context = ssl._create_unverified_context

Very possible and very dangerous. I am considering using this in the event of an ssl error, but it runs the risk of a MITM to our api requests.

Worst damage they could do is forge replies from Poloniex, which is not the most dangerous thing. Can they pull API and secret from the request?

rnevet commented 7 years ago

@Evanito I would not add this, bypassing ssl certificate should only be done by someone understanding the risks. The ssl fail is a local configuration issue, not a Bot issue -> no code change.

sgwanlee commented 7 years ago

Hi, I know it's out-dated issue. I have same problem and here's how i fix it.

python 2.7.14 window server 2016

poloniex use globalsign for ssl certificate. so I copy and paste globalsign's root certificate into python's cacert.pem file.

here's link for globalsign

and here's python script to check where your cacert.pem file is. from requests.utils import DEFAULT_CA_BUNDLE_PATH; print(DEFAULT_CA_BUNDLE_PATH)