Token authentication with Waitress server bundled with Pyinstaller

88 views
Skip to first unread message

Simone Orlando

unread,
Mar 17, 2023, 2:11:59 PM3/17/23
to PyInstaller
Are you aware of any incompatibilities with Waitress server once is bundled using pyinstaller?

I have a Flask app served by a Waitress server which receive some requests with a token authentication. This token is just a file with the following line:
Authorization: Bearer ... here the token ...

I have no problem with this app. But, once i bundle with PyInstaller, even if the server starts without any errors, when I go to do some requests I receive a strange authentication problem:

Traceback (most recent call last): File "jwt\algorithms.py", line 257, in prepare_key File "cryptography\hazmat\primitives\serialization\base.py", line 24, in load_pem_private_key File "cryptography\hazmat\backends\openssl\backend.py", line 949, in load_pem_private_key File "cryptography\hazmat\backends\openssl\backend.py", line 1201, in _load_key File "cryptography\hazmat\backends\openssl\backend.py", line 1257, in _handle_key_loading_error ValueError: ('Could not deserialize key data. The data may be in an incorrect format, it may be encrypted with an unsupported algorithm, or it may be an unsupported key type (e.g. EC curves with explicit parameters).', [_OpenSSLErrorWithText(code=503841036, lib=60, reason=524556, reason_text=b'error:1E08010C:DECODER routines::unsupported')]) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "flask\app.py", line 2528, in wsgi_app File "flask\app.py", line 1825, in full_dispatch_request File "flask_cors\extension.py", line 165, in wrapped_function File "flask\app.py", line 1823, in full_dispatch_request File "flask\app.py", line 1799, in dispatch_request File "flask_jwt_extended\view_decorators.py", line 153, in decorator File "flask_jwt_extended\view_decorators.py", line 89, in verify_jwt_in_request File "flask_jwt_extended\view_decorators.py", line 323, in _decode_jwt_from_request File "flask_jwt_extended\utils.py", line 127, in decode_token File "flask_jwt_extended\jwt_manager.py", line 553, in _decode_jwt_from_config File "flask_jwt_extended\tokens.py", line 94, in _decode_jwt File "jwt\api_jwt.py", line 168, in decode File "jwt\api_jwt.py", line 120, in decode_complete File "jwt\api_jws.py", line 202, in decode_complete File "jwt\api_jws.py", line 298, in _verify_signature File "jwt\algorithms.py", line 259, in prepare_key File "cryptography\hazmat\primitives\serialization\base.py", line 34, in load_pem_public_key File "cryptography\hazmat\backends\openssl\backend.py", line 996, in load_pem_public_key File "cryptography\hazmat\backends\openssl\backend.py", line 1257, in _handle_key_loading_error ValueError: ('Could not deserialize key data. The data may be in an incorrect format, it may be encrypted with an unsupported algorithm, or it may be an unsupported key type (e.g. EC curves with explicit parameters).', [_OpenSSLErrorWithText(code=75497580, lib=9, reason=108, reason_text=b'error:0480006C:PEM routines::no start line')])

Do you have any idea what could be the source of the problem? 
I'm using the same file for the authentication. I even tried to switch to the default built-in server provided by Flask and it turns out this error disappear. So it seems something related to Waitress, but only once is bundle with PyInstaller, because normally it works.
Thank you.
Reply all
Reply to author
Forward
0 new messages