SSL:CERTIFICATE_VERIFY_FAILED在AWS EC2上运行的python代码出错

时间:2021-10-25 18:15:43
import krakenex
import decimal
import time

def now():
    return decimal.Decimal(time.time())

k_public=krakenex.API()
eth_ret = k_public.query_public('Ticker', req = {'pair': 'XETHZEUR', 'since': now()})
print(eth_ret)

The above python code is trying to make a request to an api services. Running it on a newly launched AWS EC2 instance (Windows Server 2012) gives the following error. There is no error when the code is running on another old instance, also with Windows Server 2012. Any advice to solve the problem? Many thanks!

上面的python代码试图向api服务发出请求。在新启动的AWS EC2实例(Windows Server 2012)上运行它会出现以下错误。代码在另一个旧实例上运行时也没有错误,也是在Windows Server 2012上运行。有什么建议可以解决这个问题吗?非常感谢!

Traceback (most recent call last):
File "test_kraken_ssl.py", line 9, in <module>
File "site-packages\krakenex\api.py", line 148, in query_public
File "site-packages\krakenex\api.py", line 130, in _query
File "site-packages\krakenex\connection.py", line 78, in _request
File "http\client.py", line 1107, in request
File "http\client.py", line 1152, in _send_request
File "http\client.py", line 1103, in endheaders
File "http\client.py", line 934, in _send_output
File "http\client.py", line 877, in send
File "http\client.py", line 1261, in connect
File "ssl.py", line 385, in wrap_socket
File "ssl.py", line 760, in __init__
File "ssl.py", line 996, in do_handshake
File "ssl.py", line 641, in do_handshake
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:719)

1 个解决方案

#1


0  

The problem can be solved by adding the domain of the api service website as trusted sites for Windows Server. Open Internet Explorer and go to Internet Options. Then under the Security Tab add something like http://*.yourdomain.com as Trusted sites.

通过将api服务网站的域添加为Windows Server的可信站点,可以解决该问题。打开Internet Explorer并转到“Internet选项”。然后在“安全”选项卡下添加http://*.yourdomain.com等可信站点。

#1


0  

The problem can be solved by adding the domain of the api service website as trusted sites for Windows Server. Open Internet Explorer and go to Internet Options. Then under the Security Tab add something like http://*.yourdomain.com as Trusted sites.

通过将api服务网站的域添加为Windows Server的可信站点,可以解决该问题。打开Internet Explorer并转到“Internet选项”。然后在“安全”选项卡下添加http://*.yourdomain.com等可信站点。