Reputation: 105
I want to add a test sentry instance that has a self signed certificate.
The app has the default RAVEN_CONFIG
RAVEN_CONFIG = {
'dsn': 'https://[email protected]/2',
# If you are using git, you can also automatically configure the
# release based on the git info.
'release': raven.fetch_git_sha(os.path.dirname(os.pardir)),
}
I tried to add 'verify_ssl':0
to the configuration dictionary to no avail.
This is the error I'm getting:
Traceback (most recent call last):
File "/opt/apps/.virtualenvs/palantir/local/lib/python2.7/site-packages/raven/transport/threaded.py", line 162, in send_sync
super(ThreadedHTTPTransport, self).send(data, headers)
File "/opt/apps/.virtualenvs/palantir/local/lib/python2.7/site-packages/raven/transport/http.py", line 47, in send
ca_certs=self.ca_certs,
File "/opt/apps/.virtualenvs/palantir/local/lib/python2.7/site-packages/raven/utils/http.py", line 62, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 431, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 449, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/opt/apps/.virtualenvs/palantir/local/lib/python2.7/site-packages/raven/utils/http.py", line 46, in https_open
return self.do_open(ValidHTTPSConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1197, in do_open
raise URLError(err)
URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)>
Upvotes: 5
Views: 6252
Reputation: 2430
Put below code in settings.py
:
# Sentry
# https://docs.sentry.io/platforms/python/guides/django/
def _get_pool_options(self, ca_certs):
return {
'num_pools': 2,
'cert_reqs': 'CERT_NONE'
}
if sentry_dsn := os.getenv('SENTRY_DSN'):
sentry_sdk.transport.HttpTransport._get_pool_options = _get_pool_options
sentry_sdk.init(dsn=sentry_dsn, integrations=[DjangoIntegration()], send_default_pii=True)
requirements.txt
file:
Django==3.1.1
sentry-sdk==0.19.4
Upvotes: 1
Reputation: 1751
This worked for me:
from raven.transport.requests import RequestsHTTPTransport
RAVEN_CONFIG = {
'transport': RequestsHTTPTransport,
'dsn': DSN
}
Note: It calls synchronously.
Upvotes: 0
Reputation: 985
overwrite sentry-python's function
def disable_sentry_ssl_check():
# disable sni warnings
import urllib3
urllib3.disable_warnings()
def _get_pool_options(self, ca_certs):
return {
"num_pools": 2,
"cert_reqs": "CERT_NONE",
}
# disable ssl check
from sentry_sdk.transport import HttpTransport
HttpTransport._get_pool_options = _get_pool_options
Upvotes: 4
Reputation: 3135
Can you try adding verify_ssl=0
to your DSN as shown the docs:
https://[email protected]/2?verify_ssl=0
Upvotes: 14