Issue
I get the following AssertionError
when running my script on a Raspberry Pi Zero W after rebooting. The error stops occurring after a few minutes, and I can interface with my Firebase database as expected without issue.
However, this is still problematic because it prevents me from successfully running the script right after the device connects to wifi.
I have also posted this as an issue in the firebase-admin-python repo.
Traceback (most recent call last):
File "/home/pi/weatherbox/48_hour_forecast.py", line 136, in <module>
render_forecast(args.location)
File "/home/pi/weatherbox/48_hour_forecast.py", line 88, in render_forecast
forecast_data_48_hours.append(darksky.get_time_machine_forecast(location, timestamp_today))
File "/home/pi/weatherbox/darksky.py", line 83, in get_time_machine_forecast
coordinates = get_lat_long(location_search)
File "/home/pi/weatherbox/darksky.py", line 16, in get_lat_long
saved_location = saved_location_ref.get()
File "/usr/local/lib/python2.7/dist-packages/firebase_admin/db.py", line 219, in get
return self._client.body('get', self._add_suffix(), params=params)
File "/usr/local/lib/python2.7/dist-packages/firebase_admin/_http_client.py", line 93, in body
resp = self.request(method, url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/firebase_admin/db.py", line 882, in request
return super(_Client, self).request(method, url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/firebase_admin/_http_client.py", line 84, in request
resp = self._session.request(method, self._base_url + url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/google/auth/transport/requests.py", line 198, in request
self._auth_request, method, url, request_headers)
File "/usr/local/lib/python2.7/dist-packages/google/auth/credentials.py", line 122, in before_request
self.refresh(request)
File "/usr/local/lib/python2.7/dist-packages/google/oauth2/service_account.py", line 320, in refresh
assertion = self._make_authorization_grant_assertion()
File "/usr/local/lib/python2.7/dist-packages/google/oauth2/service_account.py", line 314, in _make_authorization_grant_assertion
token = jwt.encode(self._signer, payload)
File "/usr/local/lib/python2.7/dist-packages/google/auth/jwt.py", line 94, in encode
signature = signer.sign(signing_input)
File "/usr/local/lib/python2.7/dist-packages/google/auth/crypt/_cryptography_rsa.py", line 126, in sign
message, _PADDING, _SHA256)
File "/usr/lib/python2.7/dist-packages/cryptography/hazmat/backends/openssl/rsa.py", line 463, in sign
algorithm, self, data
File "/usr/lib/python2.7/dist-packages/cryptography/hazmat/backends/openssl/rsa.py", line 241, in _rsa_sig_sign
assert errors[0].lib == backend._lib.ERR_LIB_RSA
AssertionError
Solution
This error is specific to the Python Cryptographic Authority (PyCA) cryptography
package, which is used by Firebase.
More details on this issue: https://github.com/pyca/cryptography/issues/4635
A possible workaround: https://github.com/firebase/firebase-admin-python/issues/234
Answered By - charliesneath