Apache not starting after installing mod_ssl

Issues related to applications and software problems
Post Reply
acrylic
Posts: 16
Joined: 2017/02/22 11:18:58

Apache not starting after installing mod_ssl

Post by acrylic » 2017/08/17 12:09:54

Not sure how I managed this...

All I did was stop httpd via systemctl, install mod_ssl and follow these instructions (editing ssl.conf):
https://uk.godaddy.com/help/apache-inst ... entos-5238

Since then I get this error when I try to start:

Code: Select all

# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2017-08-17 14:06:55 CEST; 3s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 9132 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 9127 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 9127 (code=exited, status=1/FAILURE)

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Apache not starting after installing mod_ssl

Post by TrevorH » 2017/08/17 12:28:37

Look in /var/log/httpd/*error_log to see if anything useful is logged there. Otherwise show the content of /etc/httpd/conf.d/ssl.conf and the output of ls -laZ on the files that the SSLCert* lines point to.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

acrylic
Posts: 16
Joined: 2017/02/22 11:18:58

Re: Apache not starting after installing mod_ssl

Post by acrylic » 2017/08/17 12:46:36

TrevorH wrote:Look in /var/log/httpd/*error_log to see if anything useful is logged there. Otherwise show the content of /etc/httpd/conf.d/ssl.conf and the output of ls -laZ on the files that the SSLCert* lines point to.
Thank you Trevor. Outputs below:

error_log

Code: Select all

[Thu Aug 17 12:25:27.589003 2017] [suexec:notice] [pid 31841] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Thu Aug 17 12:25:27.589731 2017] [ssl:emerg] [pid 31841] AH02311: Fatal error initialising mod_ssl, exiting. See /etc/httpd/logs/ssl_error_log for more information
[Thu Aug 17 12:26:59.331447 2017] [suexec:notice] [pid 32016] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Thu Aug 17 12:26:59.332165 2017] [ssl:emerg] [pid 32016] AH02311: Fatal error initialising mod_ssl, exiting. See /etc/httpd/logs/ssl_error_log for more information
[Thu Aug 17 12:27:53.211792 2017] [suexec:notice] [pid 32121] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Thu Aug 17 12:27:53.212508 2017] [ssl:emerg] [pid 32121] AH02311: Fatal error initialising mod_ssl, exiting. See /etc/httpd/logs/ssl_error_log for more information
[Thu Aug 17 14:04:00.262741 2017] [suexec:notice] [pid 8806] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Thu Aug 17 14:04:00.263465 2017] [ssl:emerg] [pid 8806] AH02311: Fatal error initialising mod_ssl, exiting. See /etc/httpd/logs/ssl_error_log for more information
[Thu Aug 17 14:06:55.449879 2017] [suexec:notice] [pid 9127] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Thu Aug 17 14:06:55.450606 2017] [ssl:emerg] [pid 9127] AH02311: Fatal error initialising mod_ssl, exiting. See /etc/httpd/logs/ssl_error_log for more information
ssl_error_log

Code: Select all

[Thu Aug 17 12:26:59.332159 2017] [ssl:emerg] [pid 32016] SSL Library Error: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
[Thu Aug 17 12:27:53.212474 2017] [ssl:warn] [pid 32121] AH01909: RSA certificate configured for 2001:41d0:8:160a:::443 does NOT include an ID which matches the server name
[Thu Aug 17 12:27:53.212490 2017] [ssl:emerg] [pid 32121] AH02238: Unable to configure RSA server private key
[Thu Aug 17 12:27:53.212504 2017] [ssl:emerg] [pid 32121] SSL Library Error: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
[Thu Aug 17 14:04:00.263433 2017] [ssl:warn] [pid 8806] AH01909: RSA certificate configured for 2001:41d0:8:160a:::443 does NOT include an ID which matches the server name
[Thu Aug 17 14:04:00.263449 2017] [ssl:emerg] [pid 8806] AH02238: Unable to configure RSA server private key
[Thu Aug 17 14:04:00.263462 2017] [ssl:emerg] [pid 8806] SSL Library Error: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
[Thu Aug 17 14:06:55.450573 2017] [ssl:warn] [pid 9127] AH01909: RSA certificate configured for 2001:41d0:8:160a:::443 does NOT include an ID which matches the server name
[Thu Aug 17 14:06:55.450589 2017] [ssl:emerg] [pid 9127] AH02238: Unable to configure RSA server private key
[Thu Aug 17 14:06:55.450602 2017] [ssl:emerg] [pid 9127] SSL Library Error: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
ssl.conf

Code: Select all

#
# When we also provide SSL we have to listen to the 
# the HTTPS port in addition.
#
Listen 443 https

##
##  SSL Global Context
##
##  All SSL configuration in this context applies both to
##  the main server and all SSL-enabled virtual hosts.
##

#   Pass Phrase Dialog:
#   Configure the pass phrase gathering process.
#   The filtering dialog program (`builtin' is a internal
#   terminal dialog) has to provide the pass phrase on stdout.
SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog

#   Inter-Process Session Cache:
#   Configure the SSL Session Cache: First the mechanism 
#   to use and second the expiring timeout (in seconds).
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)
SSLSessionCacheTimeout  300

#   Pseudo Random Number Generator (PRNG):
#   Configure one or more sources to seed the PRNG of the 
#   SSL library. The seed data should be of good random quality.
#   WARNING! On some platforms /dev/random blocks if not enough entropy
#   is available. This means you then cannot use the /dev/random device
#   because it would lead to very long connection times (as long as
#   it requires to make more entropy available). But usually those
#   platforms additionally provide a /dev/urandom device which doesn't
#   block. So, if available, use this one instead. Read the mod_ssl User
#   Manual for more details.
SSLRandomSeed startup file:/dev/urandom  256
SSLRandomSeed connect builtin
#SSLRandomSeed startup file:/dev/random  512
#SSLRandomSeed connect file:/dev/random  512
#SSLRandomSeed connect file:/dev/urandom 512

#
# Use "SSLCryptoDevice" to enable any supported hardware
# accelerators. Use "openssl engine -v" to list supported
# engine names.  NOTE: If you enable an accelerator and the
# server does not start, consult the error logs and ensure
# your accelerator is functioning properly. 
#
SSLCryptoDevice builtin
#SSLCryptoDevice ubsec

##
## SSL Virtual Host Context
##

<VirtualHost _default_:443>

# General setup for the virtual host, inherited from global configuration
#DocumentRoot "/var/www/html"
#ServerName www.example.com:443

# Use separate log files for the SSL virtual host; note that LogLevel
# is not inherited from httpd.conf.
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn

#   SSL Engine Switch:
#   Enable/Disable SSL for this virtual host.
SSLEngine on

#   SSL Protocol support:
# List the enable protocol levels with which clients will be able to
# connect.  Disable SSLv2 access by default:
SSLProtocol all -SSLv2

#   SSL Cipher Suite:
#   List the ciphers that the client is permitted to negotiate.
#   See the mod_ssl documentation for a complete list.
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA

#   Speed-optimized SSL Cipher configuration:
#   If speed is your main concern (on busy HTTPS servers e.g.),
#   you might want to force clients to specific, performance
#   optimized ciphers. In this case, prepend those ciphers
#   to the SSLCipherSuite list, and enable SSLHonorCipherOrder.
#   Caveat: by giving precedence to RC4-SHA and AES128-SHA
#   (as in the example below), most connections will no longer
#   have perfect forward secrecy - if the server's key is
#   compromised, captures of past or future traffic must be
#   considered compromised, too.
#SSLCipherSuite RC4-SHA:AES128-SHA:HIGH:MEDIUM:!aNULL:!MD5
#SSLHonorCipherOrder on 

#   Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate.  If
# the certificate is encrypted, then you will be prompted for a
# pass phrase.  Note that a kill -HUP will prompt again.  A new
# certificate can be generated using the genkey(1) command.
SSLCertificateFile /usr/share/httpd/ssl-certs/7e8014176152ccdd.crt

#   Server Private Key:
#   If the key is not combined with the certificate, use this
#   directive to point at the key file.  Keep in mind that if
#   you've both a RSA and a DSA private key you can configure
#   both in parallel (to also allow the use of DSA ciphers, etc.)
SSLCertificateKeyFile /usr/share/httpd/ssl-certs/acry.eu.key

#   Server Certificate Chain:
#   Point SSLCertificateChainFile at a file containing the
#   concatenation of PEM encoded CA certificates which form the
#   certificate chain for the server certificate. Alternatively
#   the referenced file can be the same as SSLCertificateFile
#   when the CA certificates are directly appended to the server
#   certificate for convinience.
#SSLCertificateChainFile /etc/pki/tls/certs/server-chain.crt

#   Certificate Authority (CA):
#   Set the CA certificate verification path where to find CA
#   certificates for client authentication or alternatively one
#   huge file containing all of them (file must be PEM encoded)
SSLCACertificateFile /usr/share/httpd/ssl-certs/gd_bundle-g2-g1.crt

#   Client Authentication (Type):
#   Client certificate verification type and depth.  Types are
#   none, optional, require and optional_no_ca.  Depth is a
#   number which specifies how deeply to verify the certificate
#   issuer chain before deciding the certificate is not valid.
#SSLVerifyClient require
#SSLVerifyDepth  10

#   Access Control:
#   With SSLRequire you can do per-directory access control based
#   on arbitrary complex boolean expressions containing server
#   variable checks and other lookup directives.  The syntax is a
#   mixture between C and Perl.  See the mod_ssl documentation
#   for more details.
#<Location />
#SSLRequire (    %{SSL_CIPHER} !~ m/^(EXP|NULL)/ \
#            and %{SSL_CLIENT_S_DN_O} eq "Snake Oil, Ltd." \
#            and %{SSL_CLIENT_S_DN_OU} in {"Staff", "CA", "Dev"} \
#            and %{TIME_WDAY} >= 1 and %{TIME_WDAY} <= 5 \
#            and %{TIME_HOUR} >= 8 and %{TIME_HOUR} <= 20       ) \
#           or %{REMOTE_ADDR} =~ m/^192\.76\.162\.[0-9]+$/
#</Location>

#   SSL Engine Options:
#   Set various options for the SSL engine.
#   o FakeBasicAuth:
#     Translate the client X.509 into a Basic Authorisation.  This means that
#     the standard Auth/DBMAuth methods can be used for access control.  The
#     user name is the `one line' version of the client's X.509 certificate.
#     Note that no password is obtained from the user. Every entry in the user
#     file needs this password: `xxj31ZMTZzkVA'.
#   o ExportCertData:
#     This exports two additional environment variables: SSL_CLIENT_CERT and
#     SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
#     server (always existing) and the client (only existing when client
#     authentication is used). This can be used to import the certificates
#     into CGI scripts.
#   o StdEnvVars:
#     This exports the standard SSL/TLS related `SSL_*' environment variables.
#     Per default this exportation is switched off for performance reasons,
#     because the extraction step is an expensive operation and is usually
#     useless for serving static content. So one usually enables the
#     exportation for CGI and SSI requests only.
#   o StrictRequire:
#     This denies access when "SSLRequireSSL" or "SSLRequire" applied even
#     under a "Satisfy any" situation, i.e. when it applies access is denied
#     and no other module can change it.
#   o OptRenegotiate:
#     This enables optimized SSL connection renegotiation handling when SSL
#     directives are used in per-directory context. 
#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
<Files ~ "\.(cgi|shtml|phtml|php3?)$">
    SSLOptions +StdEnvVars
</Files>
<Directory "/var/www/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>

#   SSL Protocol Adjustments:
#   The safe and default but still SSL/TLS standard compliant shutdown
#   approach is that mod_ssl sends the close notify alert but doesn't wait for
#   the close notify alert from client. When you need a different shutdown
#   approach you can use one of the following variables:
#   o ssl-unclean-shutdown:
#     This forces an unclean shutdown when the connection is closed, i.e. no
#     SSL close notify alert is send or allowed to received.  This violates
#     the SSL/TLS standard but is needed for some brain-dead browsers. Use
#     this when you receive I/O errors because of the standard approach where
#     mod_ssl sends the close notify alert.
#   o ssl-accurate-shutdown:
#     This forces an accurate shutdown when the connection is closed, i.e. a
#     SSL close notify alert is send and mod_ssl waits for the close notify
#     alert of the client. This is 100% SSL/TLS standard compliant, but in
#     practice often causes hanging connections with brain-dead browsers. Use
#     this only for browsers where you know that their SSL implementation
#     works correctly. 
#   Notice: Most problems of broken clients are also related to the HTTP
#   keep-alive facility, so you usually additionally want to disable
#   keep-alive for those clients, too. Use variable "nokeepalive" for this.
#   Similarly, one has to force some clients to use HTTP/1.0 to workaround
#   their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
#   "force-response-1.0" for this.
BrowserMatch "MSIE [2-5]" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0

#   Per-Server Logging:
#   The home of a custom SSL log file. Use this when you want a
#   compact non-error SSL logfile on a virtual host basis.
CustomLog logs/ssl_request_log \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost>  

Also this:

ls -laZ /usr/share/httpd/ssl-certs/
drwxr-xr-x root root ? .
drwxr-xr-x root root ? ..
-rwxr-xr-x root root ? 7e8014176152ccdd.crt
-rwxr-xr-x root root ? acry.eu.csr
-rwxr-xr-x root root ? acry.eu.key
-rwxr-xr-x root root ? gd_bundle-g2-g1.crt

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Apache not starting after installing mod_ssl

Post by TrevorH » 2017/08/17 12:59:32

routines:X509_check_private_key:key values mismatch
Looks like the significant error there. Are you sure you used the right key file for the cert in use? Or that you either removed the passphrase from it or supplied it in a way that works? Also, I suspect the permissions on the files are not what they should be though that may not be anything to do with the current problem. Your cert and key are world readable which means that anyone that can get access to the machine can read them.

/usr/share/httpd/ssl-certs/ is not a standard location for ssl certs. I've seen /etc/httpd/conf.d/ssl.d/ used or /etc/pki/tls/certs/ but never anything under /usr. That may not affect you at the present time but once you fix the next thing...

Also, you have selinux disabled on a web server which really isn't a good idea. It's there to protect you and you've turned it off.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

acrylic
Posts: 16
Joined: 2017/02/22 11:18:58

Re: Apache not starting after installing mod_ssl

Post by acrylic » 2017/08/17 13:05:06

TrevorH wrote:
routines:X509_check_private_key:key values mismatch
Looks like the significant error there. Are you sure you used the right key file for the cert in use? Or that you either removed the passphrase from it or supplied it in a way that works? Also, I suspect the permissions on the files are not what they should be though that may not be anything to do with the current problem. Your cert and key are world readable which means that anyone that can get access to the machine can read them.

/usr/share/httpd/ssl-certs/ is not a standard location for ssl certs. I've seen /etc/httpd/conf.d/ssl.d/ used or /etc/pki/tls/certs/ but never anything under /usr. That may not affect you at the present time but once you fix the next thing...

Also, you have selinux disabled on a web server which really isn't a good idea. It's there to protect you and you've turned it off.
I will rekey and regen my cert, and try again. Thank you.

SELinux did not play well with my QEMU port redirection script, or a few other things for that matter.

Truth be told I am rather new to the application side of security, I am a Network Engineer gone linux - so I have configured a pretty strict firewall and I run fail2ban, but the application side of security is still an enigma.

I'll research how to work with SELinux.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Apache not starting after installing mod_ssl

Post by TrevorH » 2017/08/17 13:10:59

The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

acrylic
Posts: 16
Joined: 2017/02/22 11:18:58

Re: Apache not starting after installing mod_ssl

Post by acrylic » 2017/08/17 14:43:17

Thanks Trevor - a rekey and regen sorted it!

Josh

Post Reply