【问题标题】:httpd with SSL will not start on OpenBSD 5.9 (amd64)带有 SSL 的 httpd 不会在 OpenBSD 5.9 (amd64) 上启动
【发布时间】: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 listOpenBSD 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


【解决方案1】:

感谢您推荐到“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 

特洛伊。

#

【讨论】:

    【解决方案2】:

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

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

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

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

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

    【讨论】:

      【解决方案3】:

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

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

      另外,请联系“OpenBSD httpd”的主要作者 Reyk Floeter reyk@openbsd.org

      【讨论】:

        【解决方案4】:

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

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

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

        【讨论】:

          猜你喜欢
          • 2013-08-18
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-02-12
          • 2017-06-13
          • 2015-12-28
          • 1970-01-01
          • 2014-03-07
          相关资源
          最近更新 更多