context.load_cert_chain和' OSError:[Errno 22]无效的参数'

时间:2016-11-25 19:18:59

标签: python-3.x sockets ssl webserver pyopenssl

我有一个问题,我不能单独解决

我尝试做什么:
我想为我未来的项目编写一个https(SSL)网络服务器。

我做了什么:
没什么,因为这个错误

问题描述:
为了测试SSL,我从python文档中复制了SSL webserver代码。
我创建了一个认证和一个私钥,然后我运行了我的程序,输入我之前在私钥中设置的密码后出现了以下错误:

context.load_cert_chain(certfile="cert.pem", keyfile="private.pem")

在为我的私钥输入密码

后抛出:OSError: [Errno 22] Invalid argument

1 个答案:

答案 0 :(得分:0)

我有同样的问题。我在密钥文件中有一个密码,但是忘记在load.cert_chain调用中添加password参数。下面的行有效。如果错误消息不是“ OSError:[Errno 22]。”而是更具体的消息,那就更好了。

ssl_ctx.load_cert_chain("server.pem", "server.key", password="xxxxx")