yts61
yts61

Reputation: 1599

SSLError: [SSL: EE_KEY_TOO_SMALL] ee key too small (_ssl.c:4022) on Ubuntu when starting jupyter notebook

I have this problem when I am trying to initiate my Jupyter Notebook in Ubuntu over the EC2 server.

SSLError: [SSL: EE_KEY_TOO_SMALL] ee key too small (_ssl.c:4022)

Originally I had the

permission error [Errno 13]

then I followed this page and fixed it by changing the ownership of the /home folder and ~/.local/share/jupyter/ folder to current user.

Now I have the SSL issue. I checked out this link as suggested, but no luck.

I then cd to my certs folder, the "mycert.pem" is there. And I am sure I replace the local host IP address with "https://" amazon url.

My error code seems not similar to this post too, though we both have key too small. But mine is "ee key ", and "_ssl.c:4022", which is different from them.

The entire error message is like this:

ubuntu@ip-172-31-15-155:~$ jupyter notebook
[I 16:53:35.24 NotebookApp] Serving notebooks from local directory: /home/ubuntu
[I 16:53:35.24 NotebookApp] Jupyter Notebook 6.4.0 is running at:
[I 16:53:35.24 NotebookApp] https://ip-172-31-15-155:8888/?token=5d6f7e3d198847e0b9008cff94deb68355701d6c6c983322
[I 16:53:35.24 NotebookApp]  or https://127.0.0.1:8888/?token=5d6f7e3d198847e0b9008cff94deb68355701d6c6c983322
[I 16:53:35.25 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 16:53:35.28 NotebookApp] 
    
    To access the notebook, open this file in a browser:
        file:///home/ubuntu/.local/share/jupyter/runtime/nbserver-22585-open.html
    Or copy and paste one of these URLs:
        https://ip-172-31-15-155:8888/?token=5d6f7e3d198847e0b9008cff94deb68355701d6c6c983322
     or https://127.0.0.1:8888/?token=5d6f7e3d198847e0b9008cff94deb68355701d6c6c983322
ERROR:asyncio:Exception in callback BaseAsyncIOLoop._handle_events(4, 1)
handle: <Handle BaseAsyncIOLoop._handle_events(4, 1)>
Traceback (most recent call last):
  File "/usr/lib/python3.8/asyncio/events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/tornado/platform/asyncio.py", line 189, in _handle_events
    handler_func(fileobj, events)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/tornado/netutil.py", line 276, in accept_handler
    callback(connection, address)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/tornado/tcpserver.py", line 288, in _handle_connection
    connection = ssl_wrap_socket(
  File "/home/ubuntu/.local/lib/python3.8/site-packages/tornado/netutil.py", line 608, in ssl_wrap_socket
    context = ssl_options_to_context(ssl_options)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/tornado/netutil.py", line 576, in ssl_options_to_context
    context.load_cert_chain(
ssl.SSLError: [SSL: EE_KEY_TOO_SMALL] ee key too small (_ssl.c:4022)
ERROR:asyncio:Exception in callback BaseAsyncIOLoop._handle_events(4, 1)
handle: <Handle BaseAsyncIOLoop._handle_events(4, 1)>
Traceback (most recent call last):
  File "/usr/lib/python3.8/asyncio/events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/tornado/platform/asyncio.py", line 189, in _handle_events
    handler_func(fileobj, events)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/tornado/netutil.py", line 276, in accept_handler
    callback(connection, address)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/tornado/tcpserver.py", line 288, in _handle_connection
    connection = ssl_wrap_socket(
  File "/home/ubuntu/.local/lib/python3.8/site-packages/tornado/netutil.py", line 608, in ssl_wrap_socket
    context = ssl_options_to_context(ssl_options)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/tornado/netutil.py", line 576, in ssl_options_to_context
    context.load_cert_chain(
ssl.SSLError: [SSL: EE_KEY_TOO_SMALL] ee key too small (_ssl.c:4022)

Upvotes: 18

Views: 36327

Answers (2)

hamza
hamza

Reputation: 11

In my case, I had a .pfx file from the client so generating a new key was not an option for me, the key size was 1024 bits but python versions 3.10+ demands that the key size must be greater than 2048 bits, so as a workaround I had to downgrade to python 3.9.1 to solve the key size error ...

Upvotes: 1

EntzY
EntzY

Reputation: 658

cd to your cert folder, and type this command:

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mycert.pem -out mycert.pem

You are right, increase your rsa to 2048, this will solve your problem. At least this solved mine.

Upvotes: 20

Related Questions