Python 无法在CherryPy 3.8.0上使用SSL
我正在尝试在CherryPy 3.8.0上使用SSL。我的基本示例在SSL上实现了ping响应 我通过以下方式设置SSL的配置:Python 无法在CherryPy 3.8.0上使用SSL,python,ssl,curl,https,cherrypy,Python,Ssl,Curl,Https,Cherrypy,我正在尝试在CherryPy 3.8.0上使用SSL。我的基本示例在SSL上实现了ping响应 我通过以下方式设置SSL的配置: # start Web Service with some configuration global_conf = { "global": { "server.environment": "production", "engine.autoreload.on": True,
# start Web Service with some configuration
global_conf = {
"global": { "server.environment": "production",
"engine.autoreload.on": True,
"engine.autoreload.frequency": 5,
"server.socket_host": "0.0.0.0",
"server.socket_port": 443,
"cherrypy.server.ssl_module": "builtin",
"cherrypy.server.ssl_certificate": "cert.pem",
"cherrypy.server.ssl_private_key": "privkey.pem",
"environment": "production",
"log.error_file": "site.log"}
}
cherrypy.config.update(global_conf)
conf = {
"/": {
"request.dispatch": cherrypy.dispatch.MethodDispatcher(),
"tools.encode.debug": True,
}
}
但是,当我调用Web服务时,会出现错误。随后是Httpie、cURL和openssl日志
Httpie日志:
> http GET https://<host>:443/ping
http: error: SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:600)
>http获取https://:443/ping
http:error:SSLError:[SSL:UNKNOWN\u PROTOCOL]未知协议(\u SSL.c:600)
卷曲日志:
> curl -v https://<host>:443/ping
* Connected to <host> (<host>) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
* Closing connection 0
curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
>curl-vhttps://:443/ping
*已连接到()端口443(#0)
*已成功设置证书验证位置:
*卡菲尔:没有
CApath:/etc/ssl/certs
*SSLv3,TLS握手,客户端hello(1):
*错误:140770FC:SSL例程:SSL23\u获取\u服务器\u你好:未知协议
*正在关闭连接0
curl:(35)错误:140770FC:SSL例程:SSL23\u GET\u SERVER\u HELLO:未知协议
OpenSSL日志:
> openssl s_client -host <host> -port 443
CONNECTED(00000003)
140197694400160:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:795:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 7 bytes and written 295 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
---
openssl s_客户端-主机-端口443
已连接(00000003)
140197694400160:错误:140770FC:SSL例程:SSL23_GET_SERVER_HELLO:未知协议:s23_clnt.c:795:
---
没有可用的对等证书
---
未发送客户端证书CA名称
---
SSL握手读取了7个字节,写入了295个字节
---
新建,(无),密码为(无)
不支持安全重新协商
压缩:无
扩展:无
---
据我所知,不同版本的CherryPy中的SSL存在一些问题。问题之一: 简单示例:
import cherrypy
class RootServer:
@cherrypy.expose
def index(self, **keywords):
return "it works!"
if __name__ == '__main__':
server_config={
'server.socket_host': '0.0.0.0',
'server.socket_port':443,
'server.ssl_module':'builtin',
'server.ssl_certificate':'cert.pem',
'server.ssl_private_key':'privkey.pem'
}
cherrypy.config.update(server_config)
cherrypy.quickstart(RootServer())
工作
可能的问题:
无效配置
从配置中删除cherrypy.
前缀:
"server.ssl_module": "builtin",
"server.ssl_certificate": "cert.pem",
"server.ssl_private_key": "privkey.pem",
我有完全相同的例外,当我有cherrypy前缀配置时。当我修好它时,一切正常
Python不支持SSL
尝试安装pyOpenSSL
并将server.ssl\u模块
替换为pyOpenSSL
无效证书
你确定你的证书是正确的吗
请看现在似乎工作正常,谢谢。问题确实是配置无效。我是从这一页上取的: