EC2 上的 Jupyter:SSL 错误 [英] Jupyter on EC2: SSL Error

查看:34
本文介绍了EC2 上的 Jupyter:SSL 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 EC2 提供 Jupyter 笔记本,但出现 SSL 错误.我正在使用这个 AMI:TensorFlow GPU - @nottombrown (ami-8ed4d0e4).我使用了自签名证书,这可能是问题的一部分.

I'm trying to serve a Jupyter notebook from EC2 but I'm getting an SSL error. I'm using this AMI: TensorFlow GPU - @nottombrown (ami-8ed4d0e4). I used a self-signed certificate and that might be part of the problem.

我查看了其他一些有类似错误的 SO 帖子,例如 thisthisthis,但他们在完全不同的上下文中得到错误,我不知道如何获得解决方案(例如设置 verify=False) 为我工作.

I've looked at several other SO posts that have a similar error such as this, this and this, but they're getting the error in a quite different context and I can't figure out how to get the solutions (such as setting verify=False) to work for me.

[E 15:52:44.954 NotebookApp] Exception in callback (<socket._socketobject object at 0x7f5f993dad00>, <function null_wrapper at 0x7f5f99319758>)
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py", line 883, in start
        handler_func(fd_obj, events)
      File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 275, in null_wrapper
        return fn(*args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/tornado/netutil.py", line 274, in accept_handler
        callback(connection, address)
      File "/usr/local/lib/python2.7/dist-packages/tornado/tcpserver.py", line 239, in _handle_connection
        do_handshake_on_connect=False)
      File "/usr/local/lib/python2.7/dist-packages/tornado/netutil.py", line 521, in ssl_wrap_socket
        return ssl.wrap_socket(socket, **dict(context, **kwargs))
      File "/usr/lib/python2.7/ssl.py", line 487, in wrap_socket
        ciphers=ciphers)
      File "/usr/lib/python2.7/ssl.py", line 241, in __init__
        ciphers)
    SSLError: [Errno 336265225] _ssl.c:355: error:140B0009:SSL routines:SSL_CTX_use_PrivateKey_file:PEM lib

推荐答案

此错误表示找不到SSL证书.

如果您尚未创建 SSL 证书:

通过在命令行(从您的主目录开始)中键入以下内容来创建一个:

Create one by typing the following into the command line (starting at your home directory):

$ mkdir certs
$ cd certs
$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem

(来自这些说明)

现在您拥有 SSL 证书:

你需要告诉 Jupyter 在哪里可以找到它.

You need to tell Jupyter where to find it.

看看 jupyter_notebook_config.py 如果你有一个(或使用 jupyter notebook --generate-config 生成一个).

Take a look at jupyter_notebook_config.py if you have one (or generate one using jupyter notebook --generate-config).

确保您有以下行:

c.NotebookApp.certfile = u'/home/ubuntu/certs/mycert.pem' #证书文件的位置

(参见 Jupyter Notebook 文档)

并确保您的自签名 SSL 证书实际上位于该位置.例如,一个常见的错误是将 certs.certs 混淆.像这样的错误将导致 Jupyter 无法找到您的 SSL 证书,从而导致您遇到的错误.

and make sure that your self-signed SSL certificate is actually at that location. A common mistake is to mix up certs with .certs for example. A mistake like this will result in Jupyter not being able to find your SSL certificate and that'll result in the error that you're getting.

这篇关于EC2 上的 Jupyter:SSL 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆