I am making a bot for Discord using discord.py. I've seen multiple threads on this but are still experiencing issues. I am on Mac an every time I try to run my script in VS Code, I get this error raise ClientConnectorCertificateError(
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discordapp.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')]
As seen here, you'll need to go to Applications/Python 3.X/ and you'll see a folder called Install Certificates.command.
Double-click that and you should be fine when you run your bot again.
To fix the issue please do the below:
Install this package: https://pypi.org/project/certifi/
pip install certifi
Go to your Terminal an paste this:
/Applications/Python\ 3.11/Install\ Certificates.command
Note: maybe you must change the Python version to your actual version
Related
I'm trying to use youtube DL with FFmpeg to download an m3u8 stream. Just recently I started receiving this error:
ERROR: Unable to download webpage: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED]
certificate verify failed: unable to get local issuer certificate (_ssl.c:992)>
(caused by URLError(SSLCertVerificationError(1,
'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed:
unable to get local issuer certificate (_ssl.c:992)')))
I know Youtube DL supports an option for nocheckcertificate but by enabling this after a couple of minutes the target machine will refuse the connection. When trying to use the same m3u8 stream on another computer, I could download the stream without any issues.
I know that someone from Youtubedl CERTIFICATE_VERIFY_FAILED suggested fixing "your system's CA certificate list". What is the process of doing this?
I tried upgrading/reinstalling python and reinstalling the latest Windows update
I also want to mention that there hasn't been any issue with downloading for the past year but recently stumbled upon this when switching proxy providers. But because the same setup works on another PC without any issue it's probably not the reason.
The system the program is running on is Windows
Edit: Another note is that downloading other public m3u8 streams works perfectly fine, so the problem is probably with the system CA SSL.
From a python app attempting to make an HTTPS request I'm hitting an error which I'm struggling to understand:
[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:1129)
I presume this is coming from OpenSSL. But besides the handshake failing, it doesn't tell me what the problem is. IE: it doesn't tell me why the handshake failed or what step of it failed.
Various links on google give things to try, but give no reason why they might work. I have tried them but nothing worked so far. Based on these results I have tried:
upgrading certifi
running the certificate install script in mac python install directory
upgrading the python version
Is there any way to get more information about this error?
Steffen Ullrich pointed out that this error is server-side. This may be useful to others debugging. For us the problem was that we were not sending a client certificate when we were supposed to be.
For now, just a work around - folks on this fourm led me to try
compare openssl ciphers (identical in both my good and bad environments)
openssl s_client -connect news.somewhere.com:563 (worked)
then add the following python code based on output from the above:
import ssl
cntxt = ssl.create_default_context()
cntxt.set_ciphers("AES256-GCM-SHA384")
import nntplib
nntp = nntplib.NNTP_SSL('news.somewhere.com', ssl_context=cntxt)
which solved the SSLV3_ALERT_HANDSHAKE_FAILURE I was getting. (You will want to select the cipher that worked in that s_client test connection to your server.)
There are a dozen library and module version differences between my two environments, but in general the old environment uses python-3.9.7 and the new (broken but now running environment) uses python-3.10.5
Hopefully this narrows things down a bit.
I have installed and configured the Databricks CLI, but when I try using it I get an error indicating that it can't find a local issuer certificate:
$ dbfs ls dbfs:/databricks/cluster_init/
Error: SSLError: HTTPSConnectionPool(host='dbc-12345678-1234.cloud.databricks.com', port=443): Max retries exceeded with url: /api/2.0/dbfs/list?path=dbfs%3A%2Fda
tabricks%2Fcluster_init%2F (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer
certificate (_ssl.c:1123)')))
Does the above error indicate that I need to install a certificate, or somehow configure my environment so that it knows how to find the correct certificate?
My environment is Windows 10 with WSL (Ubuntu 20.04) (the command above is from WSL/Ubuntu command line).
The Databricks CLI was installed into an Anaconda environment including the following certificates and SSL packages:
$ conda list | grep cert
ca-certificates 2020.6.20 hecda079_0 conda-forge
certifi 2020.6.20 py38h32f6830_0 conda-forge
$ conda list | grep ssl
openssl 1.1.1g h516909a_1 conda-forge
pyopenssl 19.1.0 py_1 conda-forge
I get a similar error when I attept to use the REST API with curl:
$ curl -n -X GET https://dbc-12345678-1234.cloud.databricks.com/api/2.0/clusters/list
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
This problem can be solved by disabling the SSL certificate verification. In Databricks CLI you can do so by specifying insecure = True in your Databricks configuration file .databrickscfg.
I established trust to my Databricks instance by setting the environment variable REQUESTS_CA_BUNDLE.
➜ databricks workspace list
Error: SSLError: HTTPSConnectionPool(host='HOSTNAME.azuredatabricks.net', port=443): Max retries exceeded with url: /api/2.0/workspace/list?path=%2F (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))
➜ export REQUESTS_CA_BUNDLE=path/to/ca-bundle
➜ databricks workspace list
Users
Shared
Repos
From GitHub Issue:
Download the root CA certificate used to sign the Databricks certificate. Determine the path to the CA bundle and set the environment variable REQUESTS_CA_BUNDLE. See SSL Cert Verification for more information.
There is a similar issue in GitHub for Azure CLI. The solution is practically the same. Combining that with the Erik's answer:
Download the certificate using your browser and save it to disk
Open you Chrome and go to the Databricks website
Press CTRL + SHIFT + I to open the dev tools
Click Security tab
Click View certificate button
Click Details tab
On the Certification Hierarchy, (the top panel), click the highest node in the tree
Click Export the selected certificate
Choose where you want to save (eg. /home/cert/certificate.crt)
Use the SET command on Windows or the export on Linux to create a env variable called REQUESTS_CA_BUNDLE and point it to the downloaded file in the Step 1. (keep in mind that this need to be done in the same machine as you are trying to use the dbfs not in the cluster) For instance:
Linux
export REQUESTS_CA_BUNDLE=/home/cert/certificate.crt
Windows
set REQUESTS_CA_BUNDLE=c:\temp\cert\certificate.crt
Try to run your command dbfs ls dbfs:/databricks/cluster_init/ again
$ dbfs ls dbfs:/databricks/cluster_init/
It should work!
I have a Discord bot I've been running on a Windows 10 VM for several months, and yesterday it stopped working with the following error:
raise ClientConnectorCertificateError(aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discordapp.com:443
ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer cerificate (_ssl.c:1108)')]
The only fix I've found online is for MacOS which involves running a .command file.
Note: The bot can be run on my main PC, but it will not run on my secondary PC or any of my VMs.
Any help would be appreciated.
Thanks!
I opened discordapp.com in my browser and it suddenly worked.
I have the follwing script:
from currency_converter import CurrencyConverter
test = CurrencyConverter('http://www.ecb.europa.eu/stats/eurofxref/eurofxref.zip')
I try to run it on machine with windows 10 and python 3.6.7 and always get this error:
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)>
Running it on other windows 10 machines with python 3.6 works fine. I tried it on this machine with python 3.7 and get the same error. What could be wrong with the python installation ?
The reason it worked on MS Edge and not in Brave is because Brave doesn't have root ca added in trusted certificates. You need to add your ROOT_CA certificate in brave browser.