sendgrid-django
sendgrid-django copied to clipboard
SSL Verification Failure on Docker Alpine Python 3.5
We are trying to get setup with Send Grid using this library and receiving the following error:
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/celery/app/trace.py", line 240, in trace_task
R = retval = fun(*args, **kwargs)
File "/usr/lib/python3.5/site-packages/celery/app/trace.py", line 438, in __protected_call__
return self.run(*args, **kwargs)
File "/var/doorman/communication/tasks.py", line 34, in send
mail.send()
File "/usr/lib/python3.5/site-packages/django/core/mail/message.py", line 342, in send
return self.get_connection(fail_silently).send_messages([self])
File "/usr/lib/python3.5/site-packages/sgbackend/mail.py", line 68, in send_messages
self.sg.client.mail.send.post(request_body=mail)
File "/usr/lib/python3.5/site-packages/python_http_client/client.py", line 204, in http_request
return Response(self._make_request(opener, request))
File "/usr/lib/python3.5/site-packages/python_http_client/client.py", line 138, in _make_request
return opener.open(request)
File "/usr/lib/python3.5/urllib/request.py", line 466, in open
response = self._open(req, data)
File "/usr/lib/python3.5/urllib/request.py", line 484, in _open
'_open', req)
File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain
result = func(*args)
File "/usr/lib/python3.5/urllib/request.py", line 1297, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/usr/lib/python3.5/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)>
Our setup is:
- Django 1.10
- Python 3.5
- Docker
- Alpine OS (latest)
@digitaldavenyc Can you please show me your Dockerfile?
Sure
FROM alpine
ENV PYTHONPATH $PYTHONPATH:/var/myapp
WORKDIR /var/myapp
COPY . ./
RUN apk add --no-cache --update wget python3 python3-dev ca-certificates musl-dev libc-dev gcc bash postgresql-dev && \
python3 -m ensurepip && \
pip3 install --upgrade pip setuptools
RUN rm -r /root/.cache && \
rm -r /usr/lib/python*/ensurepip
RUN pip3 install --upgrade pip && \
pip3 install -r requirements-dev.txt
EXPOSE 8030
CMD gunicorn --reload --bind 0.0.0.0:8030 --pythonpath '/var/myapp' myapp.wsgi:application
@digitaldavenyc What is sendgrid-django and python-sedngrid versions?
sendgrid-django==4.0.4
python-sendgrid==3.6.3
That seems like an error from the SG client. More specifically, looks like an issue from the API itself. @thinkingserious any insights?
@elbuo8,
Hopefully the last comment on this thread will help: https://github.com/sendgrid/sendgrid-python/issues/229
+1
This seems to be a solution: https://stackoverflow.com/a/42334357