AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 416612
Accepted
blueFast
blueFast
Asked: 2012-08-12 03:20:39 +0800 CST2012-08-12 03:20:39 +0800 CST 2012-08-12 03:20:39 +0800 CST

Apache:SSLCertificateKeyFile:文件不存在或为空

  • 772

我正在为Apache 2. 我的系统是Ubuntu Server 10.04 LTS。我的虚拟主机配置中有以下与 SSL 相关的设置:

SSLEngine On
SSLCertificateKeyFile /etc/ssl/private/server.insecure.key
SSLCertificateFile    /etc/ssl/certs/portal.selfsigned.crt

(旁注:我正在使用.insecure密钥文件,因为该文件不受密码保护,我想清楚地看到它是一个不安全的密钥文件)

所以,当我重新启动 apache 时,我收到以下消息:

Syntax error on line 39 of /etc/apache2/sites-enabled/500-portal-https:
SSLCertificateKeyFile: file '/etc/ssl/private/server.insecure.key' does not exist or is empty
Error in syntax. Not restarting.

但是文件在那里,而且不是空的(实际上它包含一个私钥):

sudo ls -l /etc/ssl/private/server.insecure.key
-rw-r----- 1 root www-data 887 2012-08-07 15:14 /etc/ssl/private/server.insecure.key
sudo ls -ld /etc/ssl/private/
drwx--x--- 2 root www-data 4096 2012-08-07 13:02 /etc/ssl/private/

我尝试使用两组 www-data 和 ssl-cert 更改所有权。我不确定在 Ubuntu 中哪个是正确的:默认情况下 Ubuntu 使用 ssl-cert,但另一方面,apache 进程使用用户 www-data 运行:它由用户 root 启动,但在某些时候更改为 www-data点,我不确定何时读取证书。

但无论如何,更换群主并没有改善这种情况。我的问题是:

  1. 我还能尝试什么让这个工作?
  2. 如何验证我的密钥文件是有效的密钥文件?
  3. 我如何验证密钥文件和证书 ( /etc/ssl/certs/portal.selfsigned.crt) 是否协同工作?

我认为 Apache 给出了误导性的错误消息,我想查明错误所在。

apache-2.2
  • 7 7 个回答
  • 98184 Views

7 个回答

  • Voted
  1. Best Answer
    blueFast
    2012-08-12T04:08:02+08:002012-08-12T04:08:02+08:00

    我发现了错误。这是因为我正在使用脚本来设置证书,而我正在执行的步骤之一是apache2ctl configtest. 错误来自这个命令,而不是来自 apache 重启,这是误导我的原因。由于我以普通用户身份运行 apache2ctl 命令,它无法访问密钥文件,因此无法访问错误消息。

    Facit:确保所有 apache 命令都使用 sudo 运行,即使是那些仅用于语法验证的命令 ( apache2ctl),因为它们也需要访问密钥。

    • 67
  2. AntonioK
    2015-01-13T06:43:35+08:002015-01-13T06:43:35+08:00

    我也收到消息

    SSLCertificateKeyFile: file '/path/to/file' does not exist or is empty
    

    虽然/path/to/file存在并具有正确的权限,只是因为 SELinux 打开并且 apache 用户无法访问该文件。

    它看起来像这样:

    $ sudo ls -laZ /etc/pki/tls/certs/
    drwxr-xr-x. root root system_u:object_r:cert_t:s0      .
    drwxr-xr-x. root root system_u:object_r:cert_t:s0      ..
    -rw-------. root root unconfined_u:object_r:cert_t:s0  this-one-works.crt
    -rw-------. root root unconfined_u:object_r:admin_home_t:s0 this-one-is-unaccessable.crt
    

    为了解决这个问题,我运行sudo restorecon -Rv /etc/pki/tls/certs/- 它将修复问题文件的 SELinux 属性。

    • 16
  3. Radamanf
    2014-09-12T05:40:52+08:002014-09-12T05:40:52+08:00

    我已经做到了,它在 CentOS 5.7 上对我有帮助

    server:~ # chcon -t cert_t /etc/pki/tls/private/my.key 
    server:~ # ls -laZ /etc/pki/tls/private/
    
    • 7
  4. dkpruett
    2015-11-08T21:22:55+08:002015-11-08T21:22:55+08:00

    我收到了类似的消息:

    SSLCertificateChainFile: file '/opt/bitnami/apache2/conf/DigiCertCA.crt\xe2\x80\x9d' does not exist or is empty

    我的问题是我使用的文本编辑器放置了一个“右引号”ascii 148 而不是普通的双引号 ascii 34;使用 unix 类型的编辑器(例如 TextWrangler)输入正确的引号并解决问题。

    • 1
  5. Rithin Prabhakar
    2020-05-03T23:33:58+08:002020-05-03T23:33:58+08:00

    /etc/ssl/private目录中的普通用户没有权限。

    请试试

    sudo apache2ctl configtest
    
    • 1
  6. user130370
    2012-08-12T15:28:45+08:002012-08-12T15:28:45+08:00

    权限是错误的,但根据您的回答,这不是问题的原因:

    drwx--x--- 2 root www-data 4096 2012-08-07 13:02 /etc/ssl/private/

    /etc/ssl/private 通常属于基于 debian 的系统上的组 ssl-cert。

    刚注意到 0710 烫发,想知道它有什么用。

    • 0
  7. Moctar
    2020-09-25T02:54:05+08:002020-09-25T02:54:05+08:00

    我也是,当我检查 httpd 语法时收到此错误消息:

    SSLCertificateFile:文件“C:/wamp64/bin/apache/apache2.4.46/conf/key/certificate.crt\xe2\x80\x9c”不存在或为空

    我的问题是我粘贴的“双引号”。所以我删除它并输入它,然后它工作正常。

    • 0

相关问题

  • Apache Django Mod_Wsgi - 自动重新加载应用程序

  • Apache:对多个虚拟主机使用相同的目录指令

  • Apache 上的子域不工作 - 找不到服务器

  • PHP 作为 CGI 还是 Apache 模块?

  • 避免将某些丢失的文件记录到 Apache2 错误日志中

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve