Ubuntu的14.04和12.04(所有測試的),64位 PIP安裝龍捲風(版本4.1)龍捲風服務器錯誤HTTPS
curl -X POST -v -k https://remote_ip:8080
錯誤如下: ```
ERROR:tornado.application:Exception in callback (<socket._socketobject object at 0x7fb670a4ad00>, <function null_wrapper at 0x7fb670a05aa0>)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py", line 840, 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 223, 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 470, in ssl_wrap_socket
return ssl.wrap_socket(socket, **dict(context, **kwargs))
File "/usr/lib/python2.7/ssl.py", line 489, in wrap_socket
ciphers=ciphers)
File "/usr/lib/python2.7/ssl.py", line 243, in __init__
ciphers)
SSLError: _ssl.c:295: Both the key & certificate files must be specified
我的服務器代碼如下所示: ```
import tornado
import tornado.web
import tornado.httpserver
import tornado.ioloop
class Docker(tornado.web.RequestHandler):
def post(self, *args, **kwargs):
self.write('1\n')
application = tornado.web.Application(
handlers=[
(r'/', Docker),
],
debug=True,
)
if __name__ == '__main__':
ssl_options={'certfile': 'certificate.crt',
'keyfile': 'privateKey.key'},
srv = tornado.httpserver.HTTPServer(application, xheaders=True, ssl_options=ssl_options)
srv.bind(8080)
srv.start()
tornado.ioloop.IOLoop.instance().start()
請注意,我使用OpenSSL生成證書和密鑰文件:
openssl genrsa -out privkey.pem 2048
openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095
特別是,當我加入一個鑰匙插入ssl_options字典,cert_reqs = ssl.CERT_NONE,enven多怪錯誤出現了:
文件/usr/local/lib/python2.7/dist-packages/tornado/netutil.py: return ssl.wrap_socket(socket, **dict(context, **kwargs))
詞典更新序列元素#0具有長度1 2是必需的
我真的非常渴望讓我的龍捲風應用程序在HTTPS下正常工作,你能幫忙嗎?
非常感謝你,我對這種可恥的疏忽感到非常羞愧...... – user3201982 2015-04-03 16:01:03
不用擔心;這是一個容易犯的錯誤,而且一旦發生這種情況可能非常棘手。 – 2015-04-03 17:19:54