Answer the question
In order to leave comments, you need to log in
How to ignore SSL in Python?
Kind time of the day,
the task was to take data from the box. portal which is built on sharepoint 2013. But it uses self-signed certificates.
I use sharepoint 0.4.2
to connect,
but when I connect, it gives me:
C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\python.exe C:/Users/kavplunav/PycharmProjects/sharepoint/index.py
Traceback (most recent call last):
File "C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\lib\urllib\request.py", line 1254, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 1106, in request
self._send_request(method, url, body, headers)
File "C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 1151, in _send_request
self.endheaders(body)
File "C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 1102, in endheaders
self._send_output(message_body)
File "C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 934, in _send_output
self.send(msg)
File "C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 877, in send
self.connect()
File "C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 1260, in connect
server_hostname=server_hostname)
File "C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\lib\ssl.py", line 377, in wrap_socket
_context=self)
File "C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\lib\ssl.py", line 752, in __init__
self.do_handshake()
File "C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\lib\ssl.py", line 988, in do_handshake
self._sslobj.do_handshake()
File "C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\lib\ssl.py", line 633, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/kavplunav/PycharmProjects/sharepoint/index.py", line 22, in <module>
main()
File "C:/Users/kavplunav/PycharmProjects/sharepoint/index.py", line 19, in main
parce_sp()
File "C:/Users/kavplunav/PycharmProjects/sharepoint/index.py", line 13, in parce_sp
for sp_list in site.lists:
File "C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\lib\site-packages\sharepoint\lists\__init__.py", line 80, in __iter__
return iter(self.all_lists)
File "C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\lib\site-packages\sharepoint\lists\__init__.py", line 36, in all_lists
result = self.opener.post_soap(LIST_WEBSERVICE, xml)
File "C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\lib\site-packages\sharepoint\site.py", line 32, in post_soap
response = self.opener.open(request, timeout=self.timeout)
File "C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\lib\urllib\request.py", line 466, in open
response = self._open(req, data)
File "C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\lib\urllib\request.py", line 484, in _open
'_open', req)
File "C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\lib\urllib\request.py", line 444, in _call_chain
result = func(*args)
File "C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\lib\urllib\request.py", line 1297, in https_open
context=self._context, check_hostname=self._check_hostname)
File "C:\Users\kavplunav\AppData\Local\Programs\Python\Python35-32\lib\urllib\request.py", line 1256, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)>
Process finished with exit code 1
Answer the question
In order to leave comments, you need to log in
Generally:
import urllib2
import ssl
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
urllib2.urlopen("https://your-test-server.local", context=ctx)
>>> requests.get('https://kennethreitz.com', verify=False)
<Response [200]>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question