【发布时间】:2016-06-07 14:00:06
【问题描述】:
在最新的 OpenBSD(digitalocean.com 上的 5.9/amd64)上,我可以使用这个 httpd.conf 文件在没有 SSL 的情况下启动 httpd...
# cat /etc/httpd.conf
interface="egress"
domain="infmgr.com"
prefork 3
types { include "/usr/share/misc/mime.types" }
#server $domain {
# listen on $interface tls port 443
# tls {
# certificate "/etc/ssl/server.crt"
# key "/etc/ssl/private/server.key"
# }
# hsts
# root "/htdocs/infmgr.com" # chrooted at /var/www/
#}
server $domain {
listen on $interface port 80
root "/htdocs/infmgr.com" # chrooted at /var/www/
# block return 301 "https://$SERVER_NAME$REQUEST_URI"
}
#
当我像这样更改注释掉的行时......
# cat /etc/httpd.conf
interface="egress"
domain="infmgr.com"
prefork 3
types { include "/usr/share/misc/mime.types" }
server $domain {
listen on $interface tls port 443
tls {
certificate "/etc/ssl/server.crt"
key "/etc/ssl/private/server.key"
}
hsts
root "/htdocs/infmgr.com" # chrooted at /var/www/
}
server $domain {
listen on $interface port 80
# root "/htdocs/infmgr.com" # chrooted at /var/www/
block return 301 "https://$SERVER_NAME$REQUEST_URI"
}
#
然后重启 httpd...
# rcctl restart httpd
httpd(ok)
httpd(ok)
#
我在日志文件中收到以下错误...
# cd /var/log
# ls -alt|head -4
total 5804
-rw-r--r-- 1 root wheel 26447 Jun 7 08:39 messages
-rw-r----- 1 root wheel 5451 Jun 7 08:39 daemon
-rw-r----- 1 root wheel 2504053 Jun 7 07:49 authlog
# tail messages
...
Jun 7 06:00:02 infmgr syslogd: restart
Jun 7 08:39:26 infmgr httpd: could not parse macro definition TLS
Jun 7 08:39:26 infmgr httpd: could not parse macro definition TLS
Jun 7 08:39:26 infmgr /bsd: httpd(40862): syscall 5 "wpath"
Jun 7 08:39:26 infmgr /bsd: crash of httpd(40862) signal 6
Jun 7 08:39:26 infmgr httpd[41393]: parent: proc_dispatch: Broken pipe
# tail -15 daemon
...
Jun 7 08:39:25 infmgr httpd[4728]: logger exiting, pid 4728
Jun 7 08:39:25 infmgr httpd[80131]: server exiting, pid 80131
Jun 7 08:39:25 infmgr httpd[85373]: server exiting, pid 85373
Jun 7 08:39:25 infmgr httpd[15598]: server exiting, pid 15598
Jun 7 08:39:25 infmgr httpd[30462]: parent terminating, pid 30462
Jun 7 08:39:26 infmgr httpd[41393]: startup
Jun 7 08:39:26 infmgr httpd[41393]: parent: proc_dispatch: Broken pipe
Jun 7 08:39:26 infmgr httpd[62127]: logger exiting, pid 62127
Jun 7 08:39:26 infmgr httpd[73062]: server exiting, pid 73062
Jun 7 08:39:26 infmgr httpd[93325]: server exiting, pid 93325
#
我专注于这两个错误... httpd 无法解析宏定义 TLS bsd httpd, syscall 5 wpath
我花了几个小时在谷歌上搜索,发现只有一个提到这可能是一个内核错误。我检查了OpenBSD 5.9 patch list、OpenBSD 5.9 -current changes log。
我已经出局了,正在寻求帮助……非常感谢!
特洛伊。 #
更新
根据客人的回答,这里有一些注意事项...
非常感谢您的帮助!
我不知道 httpd -d 和直接运行命令。查看 /etc/rc.d/httpd 脚本,应该很明显 :) 我将不得不再处理一些。
相应目录中的 server.crt 和 server.key 正确。我在其他地方找到了一组命令,这些命令生成了可以比较的哈希值,理论上证明两者应该可以工作。我什至将它们复制到 chrooted 目录中,它什么也没做:/
'httpd -n'返回'配置OK'...
我确实对 /etc/rc.config.local 文件进行了一些更改,将参数设置为“-DSSL”。看到 SSL 宏解析错误(上图),我用“-DTLS”替换只是为了看到错误将替换为 TLS 而不是 SSL。它在错误中继续使用 SSL。在调试语句之后,它更改为 TLS,所以我从本地配置中删除了“-DTLS”......并修复了解析错误。剩下的就是 'crash' 和 'wpath' 错误。
我使用的是 OpenBSD 的最新版本,2016 年 6 月 2 日。
更新
我创建了这个脚本来检查证书...
# httpd_cert_verify.sh
echo "compare the following md5 hashes. They should be the same..."
openssl rsa -noout -modulus -in /etc/ssl/private/server.key | openssl md5
openssl x509 -noout -modulus -in /etc/ssl/server.crt | openssl md5
echo "Check the permissions on these files, they should be readable by 'system' (-r--------)"
ls -al /etc/ssl/private/server.key
ls -al /etc/ssl/server.crt
运行它得到以下结果。
# sh httpd_cert_verify.sh
compare the following md5 hashes. They should be the same...
Enter pass phrase for /etc/ssl/private/server.key:
(stdin)= 0e8abeb155ad81a8a8db0f6036fcca13
(stdin)= 0e8abeb155ad81a8a8db0f6036fcca13
Check the permissions on these files, they should be readable by 'system' (-r--------)
-r-------- 1 root wheel 1858 Jun 5 19:40 /etc/ssl/private/server.key
-rw-r--r-- 1 root wheel 2176 Jun 5 19:39 /etc/ssl/server.crt
#
【问题讨论】:
-
我根本无法复制这个。我尝试了 5.9-release 和 -current (几天前)。甚至注册了 Digitalocean 并在那里尝试过,看看那里是否发生了一些奇怪的事情。您可以运行
ktrace -i httpd -vvd(希望它会崩溃),然后运行kdump并发布最后20-30 行左右吗?请注意这一点,因为 kdump 输出可能包含您的 TLS 证书密钥。 -
澄清一下;问题是承诺失败。即使您的钥匙有问题,也不应该发生这种情况。几乎可以肯定某处存在错误。 ktrace 输出应该显示它在被杀死之前试图打开哪个文件进行写入,这将有助于指出原因。
-
没关系,我想通了。您需要从您的私钥中删除密码。 httpd 不支持。我希望在 libssl 深处有一个不起眼的角落案例,但现实从来没有那么有趣:-(
标签: httpd.conf openbsd