尝试使用LetsEncrypt在Python中运行SSL封装的BaseHTTPServer失败

ReactingToAngularVues

我有一个BaseHTTPServer在Python中使用的可正常使用的HTTP服务器,因此我尝试添加一个SSL证书以允许使用LetsEncrypt进行HTTPS,现在它不会提供任何文件或响应。不会引发任何异常或错误,也不会提供任何内容。

server_address = ('0.0.0.0', 80)
httpd = HTTPServer(server_address, MyHandler)
# I can comment out the following line and it'll work
httpd.socket = ssl.wrap_socket(httpd.socket, keyfile=ssl_key, certfile=ssl_cert, server_side=True)
httpd.serve_forever()

#ssl_key = '/etc/letsencrypt/live/example.com/privkey.pem'
#ssl_cert = '/etc/letsencrypt/live/example.com/fullchain.pem'

MyHandler以下是哪里

class MyHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(204)
        self.send_header("Content-Type", "text/html")
        self.end_headers()
        return

    def do_POST(self):
        self.send_response(204)
        self.send_header("Content-Type", "text/html")
        self.end_headers()
        return

尝试从Web浏览器访问网站https://example.com将返回标准的无响应“找不到服务器”。

我按照以下说明使用LetsEncrypt生成证书:https ://certbot.eff.org/#ubuntuxenial-other

sudo apt-get install letsencrypt

其次是:

letsencrypt certonly --standalone -d example.com

有什么办法可以让我轻松地找出问题所在?使用Python 3.5。如果需要,很乐意提供其他信息。

斯蒂芬·乌尔里希(Steffen Ullrich)
server_address = ('0.0.0.0', 80)

尝试从Web浏览器访问网站https://example.com将返回标准的无响应“找不到服务器”。

https://host没有明确的端口规范意味着在https协议的默认端口443上访问服务器。但是,您已经将服务器设置为使用中的端口80 server_address

解决此问题的方法有两种:要么在URL中为https明确指定非标准端口,https://host:80要么将端口的端口号server_address从80更改为443。最后一种选择可能更好。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

无法在Docker中运行BaseHTTPServer

Virtualenv pip ssl-尝试安装任何软件包时失败。错误:“ Python中的ssl模块不可用”

使用flatMap移除集合中的尝试失败

IO :: Socket :: SSL:SSL连接尝试失败

如何在python中同时使用封装和继承

使用cert-manager istio ingress和LetsEncrypt在kubernetes中配置SSL证书

尝试在我的 python 代码中使用“.append”,但导致编辑器持续失败。似乎在 IDLE 上完美运行

尝试(失败)在VSC终端中使用tsc在Visual Studio Code中运行(成功安装)TypeScript编译器

尝试(失败)使用python美丽的汤从Google财务中抓取财务数据

使用 Selenium webdriver for Chrome 的 Python 脚本,尝试(但失败)打印列表框中包含的元素

尝试在 PHP 中运行 python 脚本

尝试使用curvefit在python中从Matlab的优化工具箱中运行lsqcurvefit的实现

为什么要在Python中使用导入BaseHTTPServer?

使用maxfile-size上传python BaseHTTPServer文件

无法使用SocketServer和BaseHTTPServer提供本地目录中的文件

Python SSL 验证失败

尝试通过Python运行宏,宏运行但执行失败后出现错误

尝试重新运行功能,直到使用请求在python中返回特定值

运行文件夹中的每个文件并使用 Python 打印失败率

尝试使用python和openimageIO提取子图像失败

Mavericks上python中的SSL证书验证失败

(何时)应尝试使用AutoCloseable构造函数进行封装吗?

如何在python中使用ssl解决握手失败?

perl IO :: Socket :: SSL SSL连接尝试失败

如何避免 - 当我们尝试使用 python 中的 pysftp 从 sftp 串行下载 50 多个文件时下载失败?

我正在尝试使用LLVM自动向量化归约循环。但是即使我运行了他们文档中给出的相同示例代码,它也失败了

尝试从XMing(Windows)运行Konsole失败

尝试运行Agalritty时快照失败

在Matomo中尝试运行等于数组的资产时,单元测试失败