SSLError( '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)'),)) in Python while accessing an url
You can use the verify=False
parameter to ignore verifying the SSL certificate, per the documentation:
r = requests.get(url, verify=False)
rikki
Updated on June 04, 2022Comments
-
rikki almost 2 years
I am writing a script that will will update a macro enabled Excel file that is present in a given url.I am using Python3.6 for this work. I decided it to first download in a local copy then update the local copy and after updating push it back to the same url. But when I am writing code to download the file I am getting the error as-
(Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)'),))
the code that I am using is-
import requests url = 'https://sharepoint.amr.ith.intel.com/sites/SKX/patchboard/Shared%20Documents/Forms/AllItems.aspx?RootFolder=%2Fsites%2FSKX%2Fpatchboard%2FShared%20Documents%2FReleaseInfo&FolderCTID=0x0120004C1C8CCA66D8D94FB4D7A0D2F56A8DB7&View={859827EF-6A11-4AD6-BD42-23F385D43AD6}/Copy of Patch_Release_Utilization' r = requests.get(url) open('Excel.xlsm', 'wb').write(r.content)
I have tried solution given in-Python requests SSL error - certificate verify failed ,but this is not working for me. How to resolve this problem?? Please help me with the solution if somebody has already tackled it.
EDIT:
I have tried using-
r=request.get(url,verify=False)
After doing this I am getting the warning as - "InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings" and also when I am trying to open the "Excel.xlsm" file so created I am getting the error message as- "Excel cannot open the file "Excel.xlsm" because the file format or file extensionis not valid.Verify that the file has not been corrupted and that the file extension matches the format of trhe file"
NOTE- I am trying to access the macro enabled Excel file(.xlsm) file
-
rikki over 5 yearsI have already tried that it is giving me warning as - "InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: urllib3.readthedocs.io/en/latest/…" and also the "Excel.xlsm" file formed is corrupted-@blhsing
-
rikki over 5 yearsIt is not downloading file.ven after doing verify=False,the status code that i am getting is 401.then I tried providing username and password,then also it is not working-@blhsing
-
blhsing over 5 yearsThe fact that you're getting a 401 error now means that you're already past the issue in your original question. This is no longer an issue with verifying the SSL certificate, but with the parameters you send to the API, which no one outside those who are contracted with Intel knows about. You will just have to figure out the API with the support engineers from Intel. As for the warning message, you will have to either install the proper SSL certificate, or turn off the warning message with
urllib3.disable_warnings()
as documented. -
rikki over 5 yearsWith the parameters to the API do you mean username,password etc??-@blhsing
-
blhsing over 5 yearsI mean the parameters after the question mark:
?RootFolder=%2Fsites%2FSKX%2Fpatchboard%2FShared%20Documents%2FReleaseInfo&FolderCTID=0x0120004C1C8CCA66D8D94FB4D7A0D2F56A8DB7&View={859827EF-6A11-4AD6-BD42-23F385D43AD6}/Copy of Patch_Release_Utilization
, but username and password are just as important. These are known by only those who are familiar with the proprietary API and those who hold the corporate accounts. -
rikki over 5 yearsbut this link when I am opening in my browser is working fine and downloading the required file-@blhsing
-
blhsing over 5 yearsTry replacing spaces in your URL with
%20
. Spaces are not valid URL characters although most browsers automatically translate them to%20
or+
for you when sent to the server. -
rikki over 5 yearsLet us continue this discussion in chat.