我尝试使用https和安全websockets(wss://)运行聊天应用程序,并且我收到以下错误。我正在使用我创建的自签名证书。如果我从Chrome桌面访问我的site,则可以使用。如果我从chrome ios访问同一站点,我收到以下错误消息。此外,从chrome ios,我收到不受信任证书的警告并接受它。所以我想让它适用于chrome ios。
[E 150516 14:01:56 http1connection:700] Uncaught exception
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tornado/http1connection.py", line 691, in _server_request_loop
ret = yield conn.read_response(request_delegate)
File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 807, in run
value = future.result()
File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 209, in result
raise_exc_info(self._exc_info)
File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 810, in run
yielded = self.gen.throw(*sys.exc_info())
File "/usr/local/lib/python2.7/dist-packages/tornado/http1connection.py", line 166, in _read_message
quiet_exceptions=iostream.StreamClosedError)
File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 807, in run
value = future.result()
File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 209, in result
raise_exc_info(self._exc_info)
File "<string>", line 3, in raise_exc_info
SSLEOFError: EOF occurred in violation of protocol (_ssl.c:581)
这是我的代码
import tornado.ioloop
import tornado.web
import tornado.options
import tornado.httpserver
import os
import tornado.websocket
import ssl
ssl.PROTOCOL_SSLv23 = ssl.PROTOCOL_TLSv1
clients = []
class IndexHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
def get(request):
request.render("index.html")
class WebSocketChatHandler(tornado.websocket.WebSocketHandler):
def open(self, *args):
print("open", "WebSocketChatHandler")
clients.append(self)
def on_message(self, message):
print message
for client in clients:
client.write_message(message)
def on_close(self):
clients.remove(self)
application = tornado.web.Application([(r'/wschat', WebSocketChatHandler), (r'/', IndexHandler)])
data_dir = '/home/bob'
#http_server = tornado.httpserver.HTTPServer(application)
http_server = tornado.httpserver.HTTPServer(application, ssl_options={
"certfile": os.path.join(data_dir, "myselfsigned.cer"),
"keyfile": os.path.join(data_dir, "myselfsigned.key"),
})
if __name__ == "__main__":
tornado.options.parse_command_line()
http_server.listen(443)
tornado.ioloop.IOLoop.instance().start()
我正在运行python 2.7.9和龙卷风4.1。我怀疑我不得不修补龙卷风,但是我已经尝试了各种各样的猴子修补并且没有成功。有人可以帮助我修补龙卷风,或者提供有关如何解决此问题的详细步骤。此外,我是SSL的新手,所以向我解释,就像我5岁那样:)
非常感谢你的时间和耐心!
答案 0 :(得分:0)
根据https://blog.httpwatch.com/2013/12/12/five-tips-for-using-self-signed-ssl-certificates-with-ios/,要在iOS上使用除Safari(包括Chrome)以外的应用程序的自签名证书,您必须将证书安装为“配置文件”。
服务器端记录的错误是无害的,不会在Tornado 4.2中详细记录。