gpt4 book ai didi

ipython-notebook - 为笔记本启动安全公共(public)服务器时出错 - IPython 2.2 和 tornado 4.0.2 (Debian)

转载 作者:行者123 更新时间:2023-12-04 07:26:45 26 4
gpt4 key购买 nike

我创建了一个新的配置文件并将其设置为可通过 https 公开访问。如 IPython 文档中所述。

在下面找到我遵循的步骤

生成哈希密码:

In [1]: from IPython.lib import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'

创建证书:
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem

并创建了一个新的配置文件。
ipython profile created publicServer

在 ~/.ipython/profile_publicServer/中编辑 ipython_notebook_config.py 文件
c = get_config()

# Kernel config
c.IPKernelApp.pylab = 'inline' # if you want plotting support always

# Notebook config
c.NotebookApp.certfile = u'/absolute/path/to/your/certificate/mycert.pem'
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.password = u'sha1:bcd259ccf...[your hashed password here]'
# It is a good idea to put it on a known, fixed port
c.NotebookApp.port = 9999

然后我从终端执行 ipython 以使用创建的配置文件启动笔记本:
ipython notebook --profile=publicServer

当我尝试使用浏览器从任何 ip(包括本地主机)访问它时
https://localhost:999

浏览器挂起并且从不加载页面。

在终端上,我收到以下错误消息
ERROR:tornado.application:Exception in callback (<socket._socketobject object at 0x7f76ba974980>, <function null_wrapper at 0x7f76ba918848>)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py", line 833, 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 201, in accept_handler
callback(connection, address)
File "/usr/local/lib/python2.7/dist-packages/tornado/tcpserver.py", line 225, in _handle_connection
do_handshake_on_connect=False)
File "/usr/local/lib/python2.7/dist-packages/tornado/netutil.py", line 434, in ssl_wrap_socket
context = ssl_options_to_context(ssl_options)
File "/usr/local/lib/python2.7/dist-packages/tornado/netutil.py", line 411, in ssl_options_to_context
context.load_cert_chain(ssl_options['certfile'], ssl_options.get('keyfile', None))
TypeError: coercing to Unicode: need string or buffer, NoneType found

有人可以帮我解决这个问题吗?

干杯

最佳答案

我遇到了一个客户这个问题。看起来 Tornado 库更新了它的工作方式,并且需要明确告知 openssl 生成的证书/ key 是同一个文件。

这是您需要的:在 ~/.ipython/profile_{yourprofile}/ipython_notebook_config.py 中,添加该行

c.NotebookApp.keyfile = u'/absolute/path/to/your/certificate/mycert.pem'

本质上,为 certfile 复制同一行,并为 certfile 替换 keyfile。

见:Running the Notebook Server ,特别是“使用 SSL/HTTPS”部分。

关于ipython-notebook - 为笔记本启动安全公共(public)服务器时出错 - IPython 2.2 和 tornado 4.0.2 (Debian),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25928071/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com