Using Python 3.4, I installed the below geolocation package
https://pypi.python.org/pypi/geolocation-python/0.2.2
I tested it in IDLE using the code below
key = 'myGoogleKey'
google = GoogleMaps(api_key=key)
addr = 'Boston MA'
location = google.search(location=addr)
it fails at the last line, generating an SSL Error
Traceback (most recent call last):
File "c:\python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 559, in urlopen
body=body, headers=headers)
File "c:\python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 345, in _make_request
self._validate_conn(conn)
File "c:\python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 782, in _validate_conn
conn.connect()
File "c:\python34\lib\site-packages\requests\packages\urllib3\connection.py", line 250, in connect
ssl_version=resolved_ssl_version)
File "c:\python34\lib\site-packages\requests\packages\urllib3\util\ssl_.py", line 285, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "c:\python34\lib\ssl.py", line 365, in wrap_socket
_context=self)
File "c:\python34\lib\ssl.py", line 583, in __init__
self.do_handshake()
File "c:\python34\lib\ssl.py", line 810, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\python34\lib\site-packages\requests\adapters.py", line 370, in send
timeout=timeout
File "c:\python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 588, in urlopen
raise SSLError(e)
requests.packages.urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
location = google.search(location=addr)
File "c:\python34\lib\site-packages\geolocation\main.py", line 18, in search
return self.geocode.search(location, lat, lng)
File "c:\python34\lib\site-packages\geolocation\geocode\main.py", line 48, in search
data = self.client.get_data(address=address, latitude=latitude, longitude=longitude)
File "c:\python34\lib\site-packages\geolocation\geocode\client.py", line 40, in get_data
return self.send_data(self.API_URL, self.query_parameters)
File "c:\python34\lib\site-packages\geolocation\client.py", line 22, in send_data
response = requests.get(url, params=params)
File "c:\python34\lib\site-packages\requests\api.py", line 69, in get
return request('get', url, params=params, **kwargs)
File "c:\python34\lib\site-packages\requests\api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "c:\python34\lib\site-packages\requests\sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "c:\python34\lib\site-packages\requests\sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "c:\python34\lib\site-packages\requests\adapters.py", line 433, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)
I used this same package and code using python 2.7 in a linux environment and it worked fine. Any ideas on how I can fix this?
Related
I'm actually trying to use "paddleocr" with python
I use a conda environnement
i followed the guide on their github : https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.5/doc/doc_en/quickstart_en.md
But when i try to execute this command :
(paddle_env) C:\Windows\system32>paddleocr --image_dir "path\image" --use_angle_cls true --lang en --use_gpu false
i get this error :
download https://paddleocr.bj.bcebos.com/PP-OCRv3/english/en_PP-OCRv3_det_infer.tar to C:\Users\PD/.paddleocr/whl\det\en\en_PP-OCRv3_det_infer\en_PP-OCRv3_det_infer.tar
Traceback (most recent call last):
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn
conn.connect()
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\connection.py", line 414, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\requests\adapters.py", line 489, in send
resp = conn.urlopen(
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
retries = retries.increment(
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\util\retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='paddleocr.bj.bcebos.com', port=443): Max retries exceeded with url: /PP-OCRv3/english/en_PP-OCRv3_det_infer.tar (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\PD\anaconda3\envs\paddle_env\Scripts\paddleocr.exe\__main__.py", line 7, in <module>
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\paddleocr\paddleocr.py", line 571, in main
engine = PaddleOCR(**(args.__dict__))
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\paddleocr\paddleocr.py", line 420, in __init__
maybe_download(params.det_model_dir, det_url)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\paddleocr\ppocr\utils\network.py", line 55, in maybe_download
download_with_progressbar(url, tmp_path)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\paddleocr\ppocr\utils\network.py", line 26, in download_with_progressbar
response = requests.get(url, stream=True)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\requests\api.py", line 73, in get
return request("get", url, params=params, **kwargs)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\requests\api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\requests\sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\requests\sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\requests\adapters.py", line 563, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='paddleocr.bj.bcebos.com', port=443): Max retries exceeded with url: /PP-OCRv3/english/en_PP-OCRv3_det_infer.tar (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)')))
paddleocr version : 2.5.0.3
python version : 3.8.13
It seems that you can not access the downlink provided by PaddleOCR, you can try to download the models on its mainpage, set rec_model_dir and det_model_dir mannually. (link)
demo image
I tried connecting to opensearch using python client but getting SSL Error.
OpenSearch Version: 2.0.1
Python Version:3.6
public IP of the opensearch host: 10.83.5.67
Here is the python code for connecting the client to opensearch:
from opensearchpy import *
host = '10.83.5.67'
port = 9200
auth = ('admin', 'admin') # For testing only. Don't store credentials in code.
ca_certs_path = '/etc/opensearch/cert.pem' # Provide a CA bundle if you use intermediate CAs with your root CA.
# Create the client with SSL/TLS enabled, but hostname verification disabled.
client = OpenSearch(
hosts = [{'host': host, 'port': port}],
http_compress = True, # enables gzip compression for request bodies
http_auth = auth,
use_ssl = True,
verify_certs = True,
ssl_assert_hostname = False,
ssl_show_warn = False,
ca_certs = ca_certs_path
)
The certificates used in opensearch.yml file are:
plugins.security.ssl.transport.pemcert_filepath: /etc/opensearch/cert.pem
plugins.security.ssl.transport.pemkey_filepath: /etc/opensearch/privkey.pem
plugins.security.ssl.transport.pemtrustedcas_filepath: /etc/opensearch/fullchain.pem
plugins.security.ssl.http.pemcert_filepath: /etc/opensearch/cert.pem
plugins.security.ssl.http.pemkey_filepath: /etc/opensearch/privkey.pem
plugins.security.ssl.http.pemtrustedcas_filepath: /etc/opensearch/fullchain.pem
This is the error I am getting:
[root#ip-10-92-3-240 pyscripts]# python3 ospy4.py
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
conn.connect()
File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 358, in connect
ssl_context=context)
File "/usr/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 367, in ssl_wrap_socket
return context.wrap_socket(sock)
File "/usr/lib64/python3.6/ssl.py", line 365, in wrap_socket
_context=self, _session=session)
File "/usr/lib64/python3.6/ssl.py", line 776, in __init__
self.do_handshake()
File "/usr/lib64/python3.6/ssl.py", line 1036, in do_handshake
self._sslobj.do_handshake()
File "/usr/lib64/python3.6/ssl.py", line 648, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:897)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/opensearchpy/connection/http_urllib3.py", line 250, in perform_request
method, url, body, retries=Retry(False), headers=request_headers, **kw
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/lib/python3.6/site-packages/urllib3/util/retry.py", line 344, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/lib/python3.6/site-packages/urllib3/packages/six.py", line 692, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
conn.connect()
File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 358, in connect
ssl_context=context)
File "/usr/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 367, in ssl_wrap_socket
return context.wrap_socket(sock)
File "/usr/lib64/python3.6/ssl.py", line 365, in wrap_socket
_context=self, _session=session)
File "/usr/lib64/python3.6/ssl.py", line 776, in __init__
self.do_handshake()
File "/usr/lib64/python3.6/ssl.py", line 1036, in do_handshake
self._sslobj.do_handshake()
File "/usr/lib64/python3.6/ssl.py", line 648, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:897)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "ospy4.py", line 31, in <module>
response = client.indices.create(index_name, body=index_body)
File "/usr/local/lib/python3.6/site-packages/opensearchpy/client/utils.py", line 177, in _wrapped
return func(*args, params=params, headers=headers, **kwargs)
File "/usr/local/lib/python3.6/site-packages/opensearchpy/client/indices.py", line 125, in create
"PUT", _make_path(index), params=params, headers=headers, body=body
File "/usr/local/lib/python3.6/site-packages/opensearchpy/transport.py", line 405, in perform_request
raise e
File "/usr/local/lib/python3.6/site-packages/opensearchpy/transport.py", line 375, in perform_request
timeout=timeout,
File "/usr/local/lib/python3.6/site-packages/opensearchpy/connection/http_urllib3.py", line 261, in perform_request
raise SSLError("N/A", str(e), e)
opensearchpy.exceptions.SSLError: ConnectionError([SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:897)) caused by: SSLError([SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:897))
[root#ip-10-92-3-240 pyscripts]#
Not sure what's wrong I am using the same certificate in opensearch-dashboard.yml file, but can't connect using python client.
Any suggestion would be really helpful.
Thanks
When using the python 3 Wikipedia module I get an SSL Certificate error. When is use set StrictSSL false the module works but I don't to do that permanently.
I was wondering if there was something I could change,I saw someone using a verify thing but I'm unsure how.
I am also not on a businesses wifi or anything, I think it is something to do with my computer or the actual code?
Here is the code:
outputs = wikipedia.summary(wikiSearch, sentences=3m)
Here is the error:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 344, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 843, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 350, in connect
ssl_context=context)
File "/usr/local/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 355, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket
session=session
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 853, in _create
self.do_handshake()
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1117, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 641, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='en.wikipedia.org', port=443): Max retries exceeded with url: /w/api.php?list=search&srprop=&srlimit=1&limit=1&srsearch=alex&srinfo=suggestion&format=json&action=query (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "dave.py", line 42, in <module>
index()
File "dave.py", line 25, in index
outputs = wikipedia.summary(wikiSearch, sentences=3)
File "/usr/local/lib/python3.7/site-packages/wikipedia/util.py", line 28, in __call__
ret = self._cache[key] = self.fn(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/wikipedia/wikipedia.py", line 231, in summary
page_info = page(title, auto_suggest=auto_suggest, redirect=redirect)
File "/usr/local/lib/python3.7/site-packages/wikipedia/wikipedia.py", line 270, in page
results, suggestion = search(title, results=1, suggestion=True)
File "/usr/local/lib/python3.7/site-packages/wikipedia/util.py", line 28, in __call__
ret = self._cache[key] = self.fn(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/wikipedia/wikipedia.py", line 103, in search
raw_results = _wiki_request(search_params)
File "/usr/local/lib/python3.7/site-packages/wikipedia/wikipedia.py", line 737, in _wiki_request
r = requests.get(API_URL, params=params, headers=headers)
File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 668, in send
history = [resp for resp in gen] if allow_redirects else []
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 668, in <listcomp>
history = [resp for resp in gen] if allow_redirects else []
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 247, in resolve_redirects
**adapter_kwargs
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='en.wikipedia.org', port=443): Max retries exceeded with url: /w/api.php?list=search&srprop=&srlimit=1&limit=1&srsearch=alex&srinfo=suggestion&format=json&action=query (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)')))
I hope someone can help! :)
import requests
spiders = requests.get('https://en.wikipedia.org/w/api.php')
print(spiders)
With above code I am getting following error:
Traceback (most recent call last):
File "C:\Python\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 554, in urlopen
self._prepare_proxy(conn)
File "C:\Python\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 750, in _prepare_proxy
conn.connect()
File "C:\Python\lib\site-packages\requests\packages\urllib3\connection.py", line 252, in connect
ssl_version=resolved_ssl_version)
File "C:\Python\lib\site-packages\requests\packages\urllib3\util\ssl_.py", line 305, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Python\lib\ssl.py", line 376, in wrap_socket
_context=self)
File "C:\Python\lib\ssl.py", line 747, in __init__
self.do_handshake()
File "C:\Python\lib\ssl.py", line 983, in do_handshake
self._sslobj.do_handshake()
File "C:\Python\lib\ssl.py", line 628, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)
Using a certificate I still get an error:
import requests
spiders = requests.get('https://en.wikipedia.org/w/api.php',cert = 'c:\python\lib\site-packages\certifi\cacert.pem',verify = True)
print(spiders)
Traceback (most recent call last):
File "C:/Python/Files/3.py", line 3, in <module>
spiders = requests.get('https://en.wikipedia.org/w/api.php',cert = 'c:\python\lib\site-packages\certifi\cacert.pem',verify = True)
File "C:\Python\lib\site-packages\requests\api.py", line 67, in get
return request('get', url, params=params, **kwargs)
File "C:\Python\lib\site-packages\requests\api.py", line 53, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python\lib\site-packages\requests\sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python\lib\site-packages\requests\sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "C:\Python\lib\site-packages\requests\adapters.py", line 447, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL] PEM lib (_ssl.c:2824)
Even when I have followed some tutorial verbatim I have encountered this issue when the instructor would have access w/o issue. Any ideas?
u can ignore SSL like this:
import requests
spiders = requests.get('https://en.wikipedia.org/w/api.php',verify = False)
print(spiders)
other solution:
from urllib.request import Request, urlopen
rq = Request('https://en.wikipedia.org/w/api.php')
response = urlopen(rq).read()
I'm trying to connect to JIRA using a Python wrapper for the Rest interface and I can't get it to work at all. I've read everything I could find so this is my last resort.
I've tried a lot of stuff including
verify=False
but nothing has worked so far.
The strange thing is that with urllib.request it does work without any SSL cert (it's just some internal cert) but the goal is to use the Python Jira wrapper so it's not really an option...
I've tried Python 3.4 and 2.7... getting desperate...
Any ideas?
The code is very simple:
import requests
r = requests.get('https://jiratest.myurl.com/rest/api/2/serverInfo')
print(r.content)
Error:
C:\Python34\python.exe C:/projects/jirascriptsx/delete_worklogs.py
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 544, in urlopen
body=body, headers=headers)
File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 341, in _make_request
self._validate_conn(conn)
File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 761, in _validate_conn
conn.connect()
File "C:\Python34\lib\site-packages\requests\packages\urllib3\connection.py", line 238, in connect
ssl_version=resolved_ssl_version)
File "C:\Python34\lib\site-packages\requests\packages\urllib3\util\ssl_.py", line 279, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Python34\lib\ssl.py", line 365, in wrap_socket
_context=self)
File "C:\Python34\lib\ssl.py", line 583, in __init__
self.do_handshake()
File "C:\Python34\lib\ssl.py", line 810, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\requests\adapters.py", line 370, in send
timeout=timeout
File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 574, in urlopen
raise SSLError(e)
requests.packages.urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/projects/jirascriptsx/delete_worklogs.py", line 4, in <module>
r = requests.get('https://jiratest.uniqa.at/rest/api/2/serverInfo')
File "C:\Python34\lib\site-packages\requests\api.py", line 69, in get
return request('get', url, params=params, **kwargs)
File "C:\Python34\lib\site-packages\requests\api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "C:\Python34\lib\site-packages\requests\sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python34\lib\site-packages\requests\sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "C:\Python34\lib\site-packages\requests\adapters.py", line 431, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)
Process finished with exit code 1
There is a problem with our infrastructure which seems to bring out a bug in the requests module where the SSL verification ignore flag doesn't work properly.
None of the solutions offered in any of the Stackoverflow posts worked.
As a workaround I'm running the code directly on the server.
If you have certificate file(Certificate.pem) and key file(Key.pem) then we can authenticate like this
cert=/path/to/certificate_file
key_file=/path/to/key_file
url=https://jiratest.myurl.com/rest/api/2/serverInfo
with requests.session() as session:
session.cert=(cert,key_file)
session.auth=(username,base64.urlsafe_b64decode(password))
response=session.get(url)
if response.status_code == 200:
json_data = response.json()