M
M
Maxim2018-05-13 14:24:49
Django
Maxim, 2018-05-13 14:24:49

Updated the ssl certificate and started having problems accepting requests, what could be the reason?

I did not make any changes to the nginx code and settings. I just made a certificate and uploaded it to the server, the front works fine, and requests to django fail with this error:

2018-05-12 08:15:14,882 [ERROR]
Internal Server Error: /api/v1/message/create
Process ID: 10
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 578, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 351, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 814, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 289, in connect
    ssl_version=resolved_ssl_version)
  File "/usr/local/lib/python3.4/site-packages/requests/packages/urllib3/util/ssl_.py", line 308, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/local/lib/python3.4/ssl.py", line 362, in wrap_socket
    _context=self)
  File "/usr/local/lib/python3.4/ssl.py", line 580, in __init__
    self.do_handshake()
  File "/usr/local/lib/python3.4/ssl.py", line 807, 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 "/usr/local/lib/python3.4/site-packages/requests/adapters.py", line 403, in send
    timeout=timeout
  File "/usr/local/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 604, 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 "/usr/local/lib/python3.4/site-packages/django/core/handlers/base.py", line 149, in get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.4/site-packages/django/core/handlers/base.py", line 147, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.4/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/app/api/controllers/message.py", line 56, in message_create
    req = requests.post(url, data=data)
  File "/usr/local/lib/python3.4/site-packages/requests/api.py", line 111, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.4/site-packages/requests/api.py", line 57, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.4/site-packages/requests/sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.4/site-packages/requests/sessions.py", line 585, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.4/site-packages/requests/adapters.py", line 477, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)

Googled this problem, for example this solution did not help. And in fact, no changes were made.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2018-05-13
@ky0

You can't just issue a certificate and "throw it on a server". At a minimum, you need to configure the web server accordingly if the site did not have HTTPS before, and if it did, re-read the configuration.
PS - if you changed the certificate to one issued by another CA, then the error may indicate the absence of the corresponding root certificate in the keystore. This is usually fixed by updating the package ca-certificates, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question