Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无法使SSL在Tornado上工作_Python_Ssl_Websocket_Tornado - Fatal编程技术网

Python 无法使SSL在Tornado上工作

Python 无法使SSL在Tornado上工作,python,ssl,websocket,tornado,Python,Ssl,Websocket,Tornado,我正在尝试通过SSL实现hiroakis的项目() 我做了必要的更改(见下文),还将证书颁发机构的公共证书添加到Firefox的受信任证书列表中。 当我打开https://localhost:8888,我明白了 SSLError: [SSL: SSLV3_ALERT_BAD_CERTIFICATE] SSLv3 alert bad certificate (_ssl.c:1750) (整个回溯): 除此之外,我将(r'/ws',SocketHandler)修改为(r'/wss',SocketH

我正在尝试通过SSL实现hiroakis的项目()

我做了必要的更改(见下文),还将证书颁发机构的公共证书添加到Firefox的受信任证书列表中。 当我打开
https://localhost:8888
,我明白了

SSLError: [SSL: SSLV3_ALERT_BAD_CERTIFICATE] SSLv3 alert bad certificate (_ssl.c:1750)
(整个回溯):

除此之外,我将
(r'/ws',SocketHandler)修改为(r'/wss',SocketHandler)

类似地,修改后的index.html(使用javascript创建套接字连接)是:

Index.html 创建CA公共证书(创建证书时,必须有一个唯一的名称(可分辨名称(DN)),该名称对于您创建的每个证书都是不同的):

创建服务器的私钥文件:

openssl genrsa -des3 -out servercakey.pem 
openssl genrsa -out server.key 
openssl req -new -out reqout.txt -key server.key 
openssl x509 -req -in reqout.txt -days 3650 -sha1 -CAcreateserial -CA root.crt -CAkey servercakey.pem -out server.crt 
openssl genrsa -out client.key 
openssl req -new -out reqout.txt -key client.key 
openssl x509 -req -in reqout.txt -days 3650 -sha1 -CAcreateserial -CA root.crt -CAkey servercakey.pem -out client.crt 
cat server.crt root.crt > server.pem
创建服务器证书请求:

openssl genrsa -des3 -out servercakey.pem 
openssl genrsa -out server.key 
openssl req -new -out reqout.txt -key server.key 
openssl x509 -req -in reqout.txt -days 3650 -sha1 -CAcreateserial -CA root.crt -CAkey servercakey.pem -out server.crt 
openssl genrsa -out client.key 
openssl req -new -out reqout.txt -key client.key 
openssl x509 -req -in reqout.txt -days 3650 -sha1 -CAcreateserial -CA root.crt -CAkey servercakey.pem -out client.crt 
cat server.crt root.crt > server.pem
使用CA私钥文件对服务器的证书进行签名:

openssl genrsa -des3 -out servercakey.pem 
openssl genrsa -out server.key 
openssl req -new -out reqout.txt -key server.key 
openssl x509 -req -in reqout.txt -days 3650 -sha1 -CAcreateserial -CA root.crt -CAkey servercakey.pem -out server.crt 
openssl genrsa -out client.key 
openssl req -new -out reqout.txt -key client.key 
openssl x509 -req -in reqout.txt -days 3650 -sha1 -CAcreateserial -CA root.crt -CAkey servercakey.pem -out client.crt 
cat server.crt root.crt > server.pem
创建客户端的私钥文件:

openssl genrsa -des3 -out servercakey.pem 
openssl genrsa -out server.key 
openssl req -new -out reqout.txt -key server.key 
openssl x509 -req -in reqout.txt -days 3650 -sha1 -CAcreateserial -CA root.crt -CAkey servercakey.pem -out server.crt 
openssl genrsa -out client.key 
openssl req -new -out reqout.txt -key client.key 
openssl x509 -req -in reqout.txt -days 3650 -sha1 -CAcreateserial -CA root.crt -CAkey servercakey.pem -out client.crt 
cat server.crt root.crt > server.pem
创建客户端证书请求:

openssl genrsa -des3 -out servercakey.pem 
openssl genrsa -out server.key 
openssl req -new -out reqout.txt -key server.key 
openssl x509 -req -in reqout.txt -days 3650 -sha1 -CAcreateserial -CA root.crt -CAkey servercakey.pem -out server.crt 
openssl genrsa -out client.key 
openssl req -new -out reqout.txt -key client.key 
openssl x509 -req -in reqout.txt -days 3650 -sha1 -CAcreateserial -CA root.crt -CAkey servercakey.pem -out client.crt 
cat server.crt root.crt > server.pem
使用CA私钥文件对客户端证书进行签名:

openssl genrsa -des3 -out servercakey.pem 
openssl genrsa -out server.key 
openssl req -new -out reqout.txt -key server.key 
openssl x509 -req -in reqout.txt -days 3650 -sha1 -CAcreateserial -CA root.crt -CAkey servercakey.pem -out server.crt 
openssl genrsa -out client.key 
openssl req -new -out reqout.txt -key client.key 
openssl x509 -req -in reqout.txt -days 3650 -sha1 -CAcreateserial -CA root.crt -CAkey servercakey.pem -out client.crt 
cat server.crt root.crt > server.pem
为服务器创建pem文件:

openssl genrsa -des3 -out servercakey.pem 
openssl genrsa -out server.key 
openssl req -new -out reqout.txt -key server.key 
openssl x509 -req -in reqout.txt -days 3650 -sha1 -CAcreateserial -CA root.crt -CAkey servercakey.pem -out server.crt 
openssl genrsa -out client.key 
openssl req -new -out reqout.txt -key client.key 
openssl x509 -req -in reqout.txt -days 3650 -sha1 -CAcreateserial -CA root.crt -CAkey servercakey.pem -out client.crt 
cat server.crt root.crt > server.pem

今天我终于找到了问题的根源

当我创建证书时,在创建证书的FQDN(完全限定域名)部分,我输入了127.0.0.1,而不是localhost)

令人惊讶的是,chrome和firefox都没有提醒我,我正在使用CA访问一个网站,而该CA的主题名与目标的主机名不匹配

只有当我尝试使用curl
curl时,我才这样做https://localhost:8888/
它提醒了我

我认为浏览器应该做到这一点,不是吗


我还注意到我的
/etc/hosts
文件已将
127.0.0.1
映射到
localhost
。那么,为什么使用curl将数据传输到localhost失败,但传输到127.0.0.1成功?

您使用的是什么版本的python我正在使用python 2.7.8现在我遇到另一个错误:
SSLError:[SSL:TLSV1\u ALERT\u UNKNOWN\u CA]TLSV1 ALERT UNKNOWN CA(\u SSL.c:1750)
您是否真的将证书保存在/keys/文件夹中,而密钥不在该文件夹中?这是不寻常的。
tlsv1警报未知CA
由客户端发回,因为它不知道并信任签署证书的CA。CA需要添加到客户端的信任存储中。如何做到这一点取决于客户。