Apache - Init: cannot open server private key file

I am running ssl on my apache running on localhost. I generated a self-signed certificate and put it in the usual place:

[david@david web]$ ll /etc/ssl/certs/
...
-rwxrwxrwx. 1 david david    977 Mar  7 13:18 localhost.crt
-rwxrwxrwx. 1 david david    712 Mar  7 13:16 localhost.csr
-rwxrwxrwx. 1 david david    963 Mar  7 13:12 localhost.key

But when I restart Apache, the server fails, and I get the following in the error log:

[Fri Mar 07 13:29:17 2014] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0
[Fri Mar 07 13:29:17 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Fri Mar 07 13:29:17 2014] [error] (13)Permission denied: Init: Can't open server private key file /etc/ssl/certs/localhost.key

Permissions look fine to me, what am I doing wrong?

+4
source share
2 answers

This is because you probably first uploaded the file to one of your home directories, and then moved them somewhere to the / etc directory. To fix the context of this file, run the following command:

restorecon -RvF /etc/ssl/certs/

and restart Apache service httpd restart.

Hope this helps.

+13

: sudo chown root: root localhost.key
: sudo chmod 600 localhost.key

,

: openssl rsa -in localhost.key -out localhost_nopp.key

SSLCertificateKeyFile, localhost_nopp.key Apache.

  , "" , Apache . /, , .

,

0

Source: https://habr.com/ru/post/1530686/


All Articles