0

I'm trying to connect to my api, but when I try to fetch access token () or just make a simple request to the endpoint /oauth/authorize, I receive this error :

    Traceback (most recent call last):
  File "venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 849, in _validate_conn
    conn.connect()
  File "venv/lib/python3.6/site-packages/urllib3/connection.py", line 356, in connect
    ssl_context=context)
  File "venv/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 372, in ssl_wrap_socket
    return context.wrap_socket(sock)
  File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket
    _context=self, _session=session)
  File "/usr/lib/python3.6/ssl.py", line 814, in __init__
    self.do_handshake()
  File "/usr/lib/python3.6/ssl.py", line 1068, in do_handshake
    self._sslobj.do_handshake()
  File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "venv/lib/python3.6/site-packages/requests/adapters.py", line 445, in send
    timeout=timeout
  File "venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "venv/lib/python3.6/site-packages/urllib3/util/retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='127.0.0.1', port=5000): Max retries exceeded with url: /oauth/authorize?response_type=code&client_id=&state=8SJIlHps6ehUrQhaKQ7h5ADS5o0CZo (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)'),))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "api.py", line 14, in <module>
    session.fetch_access_token(uri)
  File "venv/lib/python3.6/site-packages/authlib/client/oauth2_session.py", line 184, in fetch_access_token
    withhold_token=True)
  File "venv/lib/python3.6/site-packages/requests/sessions.py", line 559, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "venv/lib/python3.6/site-packages/authlib/client/oauth2_session.py", line 296, in request
    method, url, auth=auth, **kwargs)
  File "venv/lib/python3.6/site-packages/requests/sessions.py", line 512, in request
    resp = self.send(prep, **send_kwargs)
  File "venv/lib/python3.6/site-packages/requests/sessions.py", line 622, in send
    r = adapter.send(request, **kwargs)
  File "venv/lib/python3.6/site-packages/requests/adapters.py", line 511, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='127.0.0.1', port=5000): Max retries exceeded with url: /oauth/authorize?response_type=code&client_id=&state=8SJIlHps6ehUrQhaKQ7h5ADS5o0CZo (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)'),))

' Connection reset by peer ' socket error don't work to me. I'm using a https connection locally and the default server from Flask. Some tips ?

Update :

I did try to set the ssl of two ways :

1 º :

import ssl

context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)

context.load_cert_chain('127.0.0.1+1.pem', '127.0.0.1+1-key.pem')

app.run(ssl_context=context)

2 º :

app.run(ssl_context=('127.0.0.1+1.pem', '127.0.0.1+1-key.pem'))
  • Did you set the https server properly? You'd better provide the full error stack. – lepture Jul 08 '18 at 01:20
  • I updated the question, sorry for bother so much –  Jul 08 '18 at 03:59
  • It is still a SSL problem. It has nothing to do with OAuth. You can try to use your current SSL config with a plain hello word Flask app. Maybe you need to ask a help for SSL dev server with Flask. – lepture Jul 08 '18 at 08:19

0 Answers0