带 SSL 的 httpd 将无法在 OpenBSD 5.9 (amd64) 上启动

httpd with SSL will not start on OpenBSD 5.9 (amd64)

在最新的 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,系统调用 5 wpath

我花了几个小时在谷歌上搜索,发现只有一个提到这可能是一个内核错误。我检查了 OpenBSD 5.9 patch list, the OpenBSD 5.9 -current changes log

我出局了,寻求帮助...非常感谢!

特洛伊。 #

更新

根据客人的回答,这里有一些注意事项...

非常感谢您的帮助!

我不知道 httpd -d 和 运行 命令直接。查看 /etc/rc.d/httpd 脚本,它应该是显而易见的 :) 我将不得不再处理一下。

相应目录中的server.crt & server.key 是正确的。我在其他地方找到了一组命令,这些命令生成的哈希值确实可以进行比较,从理论上证明这两者应该有效。我什至将它们复制到 chrooted 目录中,该目录什么也没做:/

'httpd -n' 返回 'configuration 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
#

我假设文件“/etc/ssl/server.crt”和“/etc/ssl/private/server.key”存在并且是正确的。

也尝试 运行 在调试模式下使用 httpd -d 和 -n 检查配置文件,而不是使用 rcctl restart httpd

如果还是不行,我觉得你应该使用最新版本:

http://ftp.openbsd.org/pub/OpenBSD/snapshots/amd64/

看看你是否遇到同样的错误。

技术细节: wpath 错误意味着它试图在文件系统上不应该写入的地方写入。见 http://man.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man2/pledge.2

我认为此时,您应该联系 misc@openbsd.org 提出问题。

此外,请联系 "OpenBSD httpd"

的主要作者 Reyk Floeter reyk@openbsd.org

我在 -current 上看到同样的错误,我猜这可能是由于最近更改了质押系统调用/httpd 中的质押更改。

您或许应该尝试 OpenBSD 的 -stable 或 -release 版本(可能您已经尝试过),它们应该可以工作。

http://ftp.openbsd.org/pub/OpenBSD/5.9/amd64/

我感谢推荐给 'misc' 邮件列表。那里的一张海报能够解决这个问题。他们表示需要从私有 ssl 密钥中删除该密钥。这就是我所做的... 卡林, 那奏效了。谢谢!

# history
 1       cd /etc/ssl/pr
 2       cd /etc/ssl/private/
 3       cp server.key server.key.backup
 4       openssl rsa -in server.key -out server.key
 5       ls -al
 6       rcctl start httpd
 7       tail /var/log/messages
 8       date
 # exit 

特洛伊

#