Certificate expiration check raises exception if private key and cert files are separate (e.g. ~/.globus/userkey.pem, ~/.globus/usercert.pem)
The certificate reloading code (consisting of ligo.gracedb.adapter.GraceDbCertAdapter
and ligo.gracedb.cert.check_certificate_experation
) fails if the user's private key and cert files are stored in separate files (e.g. ~/.globus/userkey.pem
, ~/.globus/usercert.pem
), because it assumes that the certificate is a string and not a tuple. Here is an example traceback:
[2020-11-15 16:53:33,135: ERROR/ForkPoolWorker-15/MainThread] Task gwcelery.tasks.raven.search[a75fbee5-82f3-4c27-955f-924e2287363f] raised unexpected: TypeError('expected str, bytes or os.PathLike object, not tuple')
Traceback (most recent call last):
File "/home/emfollow-playground/.local/lib/python3.7/site-packages/celery/app/trace.py", line 385, in trace_task
R = retval = fun(*args, **kwargs)
File "/home/emfollow-playground/.local/lib/python3.7/site-packages/celery/app/trace.py", line 650, in __protected_call__
return self.run(*args, **kwargs)
File "/home/emfollow-playground/.local/lib/python3.7/site-packages/sentry_sdk/integrations/celery.py", line 197, in _inner
reraise(*exc_info)
File "/home/emfollow-playground/.local/lib/python3.7/site-packages/sentry_sdk/_compat.py", line 54, in reraise
raise value
File "/home/emfollow-playground/.local/lib/python3.7/site-packages/sentry_sdk/integrations/celery.py", line 192, in _inner
return f(*args, **kwargs)
File "/home/emfollow-playground/gwcelery/tasks/raven.py", line 161, in search
event = gracedb_events.SE(gracedb_id, gracedb=legacy_gracedb.client)
File "/home/emfollow-playground/.local/lib/python3.7/site-packages/ligo/raven/gracedb_events.py", line 143, in __init__
superevent = self.gracedb.superevent(superevent_id).json()
File "/home/emfollow-playground/.local/lib/python3.7/site-packages/ligo/gracedb/rest.py", line 833, in superevent
superevent_id=superevent_id))
File "/home/emfollow-playground/.local/lib/python3.7/site-packages/requests/sessions.py", line 555, in get
return self.request('GET', url, **kwargs)
File "/home/emfollow-playground/.local/lib/python3.7/site-packages/ligo/gracedb/client.py", line 246, in request
hooks=hooks, stream=stream, verify=verify, cert=cert, json=json)
File "/home/emfollow-playground/.local/lib/python3.7/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/home/emfollow-playground/.local/lib/python3.7/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/home/emfollow-playground/.local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/home/emfollow-playground/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 688, in urlopen
conn = self._get_conn(timeout=pool_timeout)
File "/home/emfollow-playground/.local/lib/python3.7/site-packages/ligo/gracedb/adapter.py", line 109, in _get_conn
if conn.unestablished_connection or not self._expired_cert():
File "/home/emfollow-playground/.local/lib/python3.7/site-packages/ligo/gracedb/adapter.py", line 95, in _expired_cert
self._reload_buffer)
File "/home/emfollow-playground/.local/lib/python3.7/site-packages/ligo/gracedb/cert.py", line 72, in check_certificate_expiration
cert = load_certificate(cert)
File "/home/emfollow-playground/.local/lib/python3.7/site-packages/ligo/gracedb/cert.py", line 42, in load_certificate
with open(cert, 'rb') as cert_obj:
TypeError: expected str, bytes or os.PathLike object, not tuple