Office365-REST-Python-Client icon indicating copy to clipboard operation
Office365-REST-Python-Client copied to clipboard

SSL certificate verify failed

Open platocha opened this issue 4 years ago • 2 comments

Hi, I have an issue on my work computer with connecting to Sharepoint Online due to SSL issue. It works on my Mac without issues.

My simple code: site_url = 'https://{company}.sharepoint.com/sites/{site}' client_credentials = ClientCredential(client_id, client_secret) ctx = ClientContext(site_url).with_credentials(client_credentials) web = ctx.web ctx.load(web) ctx.execute_query() print("Web title: {0}".format(web.properties['Title']))

Errors that I get: ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833) requests.exceptions.SSLError: HTTPSConnectionPool(host='accounts.accesscontrol.windows.net', port=443): Max retries exceeded with url: /76a2ae5a-9f00-4f6b-95ed-5d33d77c4d61/tokens/OAuth/2 (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),))

I have tried disabling SSL ( #61 ), but something changed I believe. I have replaced 'get_pending_request()' with 'pending_request()', but with or without this line I get the same SSL error.

site_url = 'https://{company}.sharepoint.com/sites/{site}' client_credentials = ClientCredential(client_id, client_secret) ctx = ClientContext(site_url).with_credentials(client_credentials) ctx.pending_request().beforeExecute += disable_ssl web = ctx.web ctx.load(web) ctx.execute_query() print("Web title: {0}".format(web.properties['Title']))

Thank you in advance for any help in resolving this issue. I was so happy that I finally found the code that is so extensive and works until I tried it on my work computer...

platocha avatar Jan 04 '21 08:01 platocha

same here, I had to change get_pending_request() to pending_request() also with no luck.

xlrashn35 avatar Jan 22 '21 16:01 xlrashn35

same issue here.. replaced et_pending_request() to pending_request() = False ... still having issues with SSL :/

coding724 avatar Mar 21 '22 17:03 coding724

Also having the same issue. Haven't found any solutions or workarounds

Klazer avatar Dec 22 '22 17:12 Klazer

@vgrem Getting same SSL error

Reference: https://github.com/vgrem/Office365-REST-Python-Client/issues/61

site_url = 'https://xxx.sharepoint.com/sites/Qlik_SE_APP_Mapping' client_credentials = ClientCredential(client_id, client_secret) ctx = ClientContext(site_url).with_credentials(client_credentials) ctx.pending_request().beforeExecute += disable_ssl web = ctx.web ctx.load(web) <office365.sharepoint.client_context.ClientContext object at 0x7faf866aa7c0> ctx.execute_query() Traceback (most recent call last): File "/home/airflow/.local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 700, in urlopen self._prepare_proxy(conn) File "/home/airflow/.local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 996, in prepare_proxy conn.connect() File "/home/airflow/.local/lib/python3.9/site-packages/urllib3/connection.py", line 414, in connect self.sock = ssl_wrap_socket( File "/home/airflow/.local/lib/python3.9/site-packages/urllib3/util/ssl.py", line 449, in ssl_wrap_socket ssl_sock = ssl_wrap_socket_impl( File "/home/airflow/.local/lib/python3.9/site-packages/urllib3/util/ssl.py", line 493, in _ssl_wrap_socket_impl return ssl_context.wrap_socket(sock, server_hostname=server_hostname) File "/usr/local/lib/python3.9/ssl.py", line 501, in wrap_socket return self.sslsocket_class._create( File "/usr/local/lib/python3.9/ssl.py", line 1041, in _create self.do_handshake() File "/usr/local/lib/python3.9/ssl.py", line 1310, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)

venkateshnyq550 avatar Feb 23 '23 15:02 venkateshnyq550