SSL issue with multiple virtual hosts on apache - apache

I’m trying to renew the certificate for a second web serviced identified by a virtual host, call it “mysubdomain2.mydomain2.com”.
I’ve generated all the required files (mysubdomain2.crt mysubdomain2.mydomain.com.key ca.pem sub.class1.server.ca.pem).
Note that I recently successfully renewed the certificate for mysubdomain1.crt.
Here's the virtual host entry in apache:
<VirtualHost *:443>
ServerName mysubdomain2.mydomain.com
ServerAdmin myname#mycomp.com
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
SSLCertificateFile /disk2/certificates/ssl/mysubdomain2.crt
SSLCertificateKeyFile /disk2/certificates/ssl/mysubdomain.mydomain.com.key
SSLCertificateChainFile /disk2/certificates/ssl/sub.class1.server.ca.pem
SSLCACertificateFile /disk2/certificates/startssl/ca.pem
SSLOptions StrictRequire
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
CustomLog /var/log/apache2/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
#</VirtualHost>
But when I restart apache, it shuts down with this error message:
“caught SIGTERM, shutting down
[Tue Jan 13 13:59:16 2015] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Tue Jan 13 13:59:17 2015] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Tue Jan 13 13:59:17 2015] [notice] Apache/2.2.16 (Ubuntu) PHP/5.3.3-1ubuntu9.5 with Suhosin-Patch mod_ssl/2.2.16 OpenSSL/0.9.8o configured -- resuming normal operations
Additionally, from this link:
https://wiki.apache.org/httpd/NameBasedSSLVHostsWithSNI
it's clear that this installation of apache has SNI installed. It seems that apache should at least start, as these are supposed to be just warning messages.
The problem SNI is supposed to solve is that without it, the host name doesn't get communicated until after the SSL connection is established, meaning that apache doesn't know which certificate to use.
But, at this point, it's simply not starting at all. I'm thinking to try regenerating the certificate and key and pem files, but I was pretty careful doing that in the first place. I'd like to understand what the real problem is.

I must have done something wrong when decrypting the secret key. I tried it again, and everything was fine.

Related

Error configuring a HTTPS forward proxy (AH02268: downstream server wanted client certificate but none are configured)

I think I'm doing several mistakes together, but I'm stuck and I'm going out crazy. And I guess the question has already been posed, but, even searching a lot, I could not find this exact case posted anywhere.
The task I'm working to is calling a remote HTTPS server through a proxy:
wget http://localhost/remote?wsdl
points to
https://someserver.com/service?wsdl
In a diagram:
(http) (https)
client ------> localhost -------> someserver.com
Using the wonderful Apache web server (really, not kidding).
The certificate exchange occurs between the proxy and the remote server and I already installed the client certificate with the private key onboard of the proxy. The customer gave me the certificates in a .p12 file.
Trying to test the wanted webservice with SoapUI and the same certificates, I got the expected behavior (everything is working fine). But now I have to call services from a middleware. For this I'm configuring a SSL Proxy with Apache.
I tried to do this in 2 ways, both unsuccessful:
1) Defining a proxy and defining the SSL parameters respectively in two files:
/etc/apache2/conf.d/mods-available/ssl.conf
/etc/apache2/conf.d/mods-available/proxy.conf
The first file contains:
# /etc/apache2/conf.d/mods-available/ssl.conf
SSLPassPhraseDialog exec:/usr/local/etc/apache2/pwf.sh # to avoid manuallly entering passphrase
SSLSessionCache shmcb:/var/cache/mod_ssl/scache(512000)
SSLSessionCacheTimeout 300
SSLRandomSeed startup file:/dev/urandom 256
SSLRandomSeed connect builtin
ErrorLog /var/log/ssl_error_log
TransferLog /var/log/ssl_access_log
LogLevel warn
SSLEngine off
SSLProtocol all -SSLv2
SSLCipherSuite DEFAULT:!EXP:!SSLv2:!DES:!IDEA:!SEED:+3DES
SSLCertificateFile /usr/local/etc/apache2/ssl.crt/certificate.pem
SSLCertificateKeyFile /usr/local/etc/apache2/ssl.key/server.key
SSLCertificateChainFile /usr/local/etc/apache2/ssl.crt/chain.pem
CustomLog /var/log/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
And the second file contains:
# /etc/apache/conf.d/mods-available/proxy.conf
SetEnv proxy-sendcl 1
SSLProxyEngine On
ProxyPass /remote https://someserver.com/service
ProxyPassReverse /remote https://someserver.com/service
I enabled these modules via:
sudo a2enmod proxy & a2enmod ssl
2) Defining a Virtual Host
/etc/apache2/conf.d/sites-available/remote.conf
this method being mutually exclusive with the previous way:
#
# remote.local
<VirtualHost SOMEIP:443>
ProxyRequests on
DocumentRoot /var/www/html/remote
ServerName someserver.com
SSLEngine on
SSLProxyEngine on
SSLCertificateFile /usr/local/etc/apache2/ssl.crt/certificate.pem
SSLCertificateKeyFile /usr/local/etc/apache2/ssl.key/server.key
SSLCertificateChainFile /usr/local/etc/apache2/ssl.crt/chain.pem
ProxyPreserveHost On
ErrorLog ${APACHE_LOG_DIR}/error_remote.log
CustomLog ${APACHE_LOG_DIR}/access_remote.log combined
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel info
<Location /remote>
ProxyPass https://someserver.com/service
ProxyPassReverse https://someserver.com/service
Order allow,deny
Allow from all
</Location>
</VirtualHost>
I enabled this with:
sudo a2ensite remote
In any of the two ways I try, I get these (identical) errors when I try to access the local URL:
[Thu Jun 11 18:39:15.724705 2020] [ssl:warn] [pid 30578] AH02268: Proxy client certificate callback: (localhost:80) downstream server wanted client certificate but none are configured
[Thu Jun 11 18:39:15.794381 2020] [proxy_http:error] [pid 30578] (20014)Internal error (specific information not available): [client ::1:49118] AH01102: error reading status line from remote server someserver.com:443
[Thu Jun 11 18:39:15.794585 2020] [proxy:error] [pid 30578] [client ::1:49118] AH00898: Error reading from remote server returned by /remote/
The chain of certificates is OK:
openssl crl2pkcs7 -nocrl -certfile chain.pem | openssl pkcs7 -print_certs -noout
Shows me all the certificate issuer and subject for CA, intermediate and server certificate:
openssl verify -CAfile ca.pem -untrusted chain.pem certificate.pem
certificate.pem: OK
Any suggestion will be appreciated, thanks in advance.
I missed to configure the certificate for the Reverse Proxy, namely the section
SSLProxyMachineCertificateFile

Trouble setting up SSL to work with MAMP 5.3

After adding a self-signed SSL certificate, I am unable to get my Drupal site to work on localhost.
I have attempted various proposed solutions that I have found online but none have gotten me past a 400 error at https://localhost/
I have uncommented the following in httpd.conf:
LoadModule ssl_module modules/mod_ssl.so
I have Listen set to port 80 in this same file. When I set it to the SSL channel, 443, Apache does not load.
In my httpd-ssl.conf file:
I have set the paths for my server.crt and server.key files correctly.
I have enabled SSLEngine
<VirtualHost *:443>
# General setup for the virtual host
DocumentRoot "/Applications/MAMP/Library/htdocs"
ServerName https://127.0.0.1:443
ServerAdmin you#example.com
ErrorLog "/Applications/MAMP/Library/logs/error_log"
TransferLog "/Applications/MAMP/Library/logs/access_log"
I have tried a variety of possibilities for the ServerName. The one above along with localhost:443 both lead to 400 errors.
I have Listen set to 443 here. Setting to 80 so it matches the httpd.conf file leads to the same result described above...not able to connect Apache.
Here is my error log for Apache:
Digest: generating secret for digest authentication ...
Digest: done
FastCGI: process manager initialized (pid 1845)
Apache/2.2.34 (Unix) mod_wsgi/3.5 Python/2.7.13 PHP/7.2.14 mod_ssl/2.2.34 OpenSSL/1.0.2o DAV/2 mod_fastcgi/mod_fastcgi-SNAP-0910052141 mod_perl/2.0.9 Perl/v5.24.0 configured -- resuming normal operations
[error] [client 127.0.0.1] client denied by server configuration: /Applications/MAMP/htdocs/.DS_Store, referer: http://localhost/MAMP/?language=English
[error] [client 127.0.0.1] client denied by server configuration: /Applications/MAMP/htdocs/.DS_Store, referer: http://localhost/MAMP/?language=English
[notice] caught SIGTERM, shutting down
I don't know enough about Apache server configuration to figure out, when I start MAMP to be able to navigate with HTTPS to my Drupal project, which is in the HTDOCs file and make it run without the 400 error.
I solved the problem by commenting out the line "Document root" above in the virtual host section.

2nd virtual host domain forwards to apache test page after ssl certificate

Ok I've seen this question asked a multitude of times but none of the posts I've come across in the 2 days I've been researching this seem to help so I'm putting it out here in hopes of someone knowing the problem.
So I have a dedicated self managed linux server using Webmin, and I had a single domain on it and added an SSL certificate and everything was going great. Then I decided to add a second domain using Webmin and it was going great too until I decided I needed an SSL certificate for that domain as well.
At no point have I had any issues with the first domain, only the 2nd one once I added the SSL certificate. At first the problem is when I tried to go to https:// and my domain, it would show my page but say it wasn't secure even though I know it should have been at this point after installing the certificate fine. Furthermore, when I would click on where Chrome said it wasn't secured, it would say the domain of my first domain on my server, not the actual domain that it should be showing.
In other words I have example1.com on the server with SSL then I added example2.com and it worked fine but once I added SSL it wouldn't be secure and when I tried to visit the HTTPS version it would say it wasn't secure and when I clicked to view the certificate it would show the example1.com name in the certificate, not the actual domain for the page I was visiting. I know I didn't accidentally try installing the wrong certificate.
I spent maybe 12 hours trying to research why this was happening and came across some pages that talked about how since I am using a single IP address for my server with multiple domains that it won't work. Then I found some info on how to determine if my server supports Server Name Indication and saw in my Apache log file that I have SNI support due to seeing the message [ssl:warn] [pid 18329] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366).
After 6 hours of tweaking with my httpd.conf and ssl.conf files I was able to see some progress, I guess... Now example1.com still is exactly the same as it was before, working perfectly, but now example2.com looks the same but if I go to https protocol it shows me the Apache Test page, but is secure, and shows the correct domain in the certificate info. if I revert to http it shows the normal page (not test page) but not secured. Furthermore the Apache test page tells me to put some files in /var/www/html which is actually the wrong place to put them as example1.com's files are at that location. So I feel like some place in the .conf files there is something wrong but I can't seem to figure it out and neither could the guy at the SSL company. Also I just noticed that when I try to access the example2.com HTTPS version and I get the Apache test page which is secure, and I try to add any page such as index.php or even a made up one that doesn't exist on my server indexjlakjlkj.php I get a 403 Forbidden, you do not have permission to access /index.php on this server.
I will paste the contents from those two .conf files now:
httpd.conf (commented lines removed so its not so long)
ServerRoot "/etc/httpd"
Listen *:80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin root#localhost
<Directory />
AllowOverride All
Require all denied
</Directory>
DocumentRoot "/var/www/html"
<Directory "/var/www">
AllowOverride All
# Allow open access:
Require all granted
</Directory>
# Further relax access to the default document root:
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog "logs/error_log"
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "logs/access_log" combined
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule mime_module>
TypesConfig /etc/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>
AddDefaultCharset UTF-8
<IfModule mime_magic_module>
MIMEMagicFile conf/magic
</IfModule>
EnableSendfile on
IncludeOptional conf.d/*.conf
<VirtualHost *>
DocumentRoot "/home"
ServerName www.example2.com:80
ServerAlias *.example2.com
<Directory /home>
allow from all
Options None
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *>
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
allow from all
Options None
Require all granted
</Directory>
ServerName www.example1.com:80
ServerAlias *.example1.com
</VirtualHost>
ServerName www.example1.com:80
KeepAlive on
ssl.conf
#
# 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 *: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 +TLSv1 +TLSv1.1 +TLSv1.2
# SSL Cipher Suite:
# List the ciphers that the client is permitted to negotiate.
# See the mod_ssl documentation for a complete list.
SSLCipherSuite HIGH:3DES:!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 /home/example2.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 /home/example2.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 /etc/pki/tls/certs/ca-bundle.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 /home/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"
SSLCACertificateFile /home/example2.com.ca-bundle
ServerName www.example2.com:443
ServerAlias *.example2.com
DocumentRoot "/home"
</VirtualHost>
<VirtualHost *: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 +TLSv1 +TLSv1.1 +TLSv1.2
# SSL Cipher Suite:
# List the ciphers that the client is permitted to negotiate.
# See the mod_ssl documentation for a complete list.
SSLCipherSuite HIGH:3DES:!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 /etc/pki/tls/certs/www_example1_com.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 /etc/ssl/certs/www.example1.com.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 /etc/pki/tls/certs/ca-bundle.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"
SSLCACertificateFile /etc/ssl/certs/www_example1_com.ca-bundle
ServerAlias *.example1.com
ServerName www.example1.com:443
DocumentRoot "/var/www/html"
</VirtualHost>
Apache error log while im at it:
[Mon Jul 16 20:45:44.042843 2018] [mpm_prefork:notice] [pid 18329] AH00171: Graceful restart requested, doing restart
[Mon Jul 16 20:45:44.621658 2018] [auth_digest:notice] [pid 18329] AH01757: generating secret for digest authentication ...
[Mon Jul 16 20:45:44.629825 2018] [lbmethod_heartbeat:notice] [pid 18329] AH02282: No slotmem from mod_heartmonitor
[Mon Jul 16 20:45:44.652054 2018] [ssl:warn] [pid 18329] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Mon Jul 16 20:45:44.874831 2018] [mpm_prefork:notice] [pid 18329] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.0.30 configured -- resuming normal operations
[Mon Jul 16 20:45:44.874916 2018] [core:notice] [pid 18329] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Mon Jul 16 20:50:44.585607 2018] [mpm_prefork:notice] [pid 18329] AH00171: Graceful restart requested, doing restart
[Mon Jul 16 20:50:45.317293 2018] [auth_digest:notice] [pid 18329] AH01757: generating secret for digest authentication ...
[Mon Jul 16 20:50:45.323182 2018] [lbmethod_heartbeat:notice] [pid 18329] AH02282: No slotmem from mod_heartmonitor
[Mon Jul 16 20:50:45.344044 2018] [ssl:warn] [pid 18329] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Mon Jul 16 20:50:45.609163 2018] [mpm_prefork:notice] [pid 18329] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.0.30 configured -- resuming normal operations
[Mon Jul 16 20:50:45.609223 2018] [core:notice] [pid 18329] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Mon Jul 16 20:57:57.607491 2018] [mpm_prefork:notice] [pid 18329] AH00171: Graceful restart requested, doing restart
[Mon Jul 16 20:57:58.316199 2018] [auth_digest:notice] [pid 18329] AH01757: generating secret for digest authentication ...
[Mon Jul 16 20:57:58.322282 2018] [lbmethod_heartbeat:notice] [pid 18329] AH02282: No slotmem from mod_heartmonitor
[Mon Jul 16 20:57:58.340258 2018] [ssl:warn] [pid 18329] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Mon Jul 16 20:57:58.521733 2018] [mpm_prefork:notice] [pid 18329] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.0.30 configured -- resuming normal operations
[Mon Jul 16 20:57:58.521798 2018] [core:notice] [pid 18329] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
I'm at a complete loss here, perhaps some extra eyes on this or some more experienced individuals can help me out here. I've spent 2 days looking over everything and not sure what to do other than perhaps purchase a multi domain SSL certificate instead of the two single certs that I bought, but not sure that will even work at this point. I'll be happy to supply any other files for review upon request. Thanks so much for looking into this for me, whomever is looking :)
Wow your configuration is a mess! You should really read https://stackoverflow.com/help/mcve.
However, I see a couple issues here:
You have 4 VirtualHosts, 2 port *, 2 port 443. This will confuse the heck out of Apache.
No indentation. Ok Apache does not care, but we do! It is very hard to read. And an empty line to separate VirtualHosts once in a while is good to have.
SSL does not like more than 1 domain on the same IP (more on that later).
Let's assume you want:
http://www.exemple1.com
http://www.example2.com
https://www.example1.com
https://www.example2.com
All on the same server, with certificates for https domains
I would do (not a complete prod ready config, just to illustrate my point):
# www.example1.com, port 80
<VirtualHost *:80>
ServerName www.example1.com
ServerAlias example1.com
ErrorLog "logs/example1_80_error_log"
CustomLog "logs/example1_80_access_log" Combined
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
allow from all
Options None
Require all granted
</Directory>
</VirtualHost>
# www.example2.com, port 80
<VirtualHost *:80>
ServerName www.example2.com
ServerAlias example2.com
ErrorLog "logs/example2_80_error_log"
CustomLog "logs/example2_80_access_log" Combined
DocumentRoot "/home"
<Directory "/home">
allow from all
Options None
Require all granted
</Directory>
</VirtualHost>
# www.example1.com, port 443
<VirtualHost 1.1.1.1:443>
ServerName www.example1.com
ServerAlias example1.com
ErrorLog "logs/example1_443_error_log"
CustomLog "logs/example1_443_access_log" Combined
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
allow from all
Options None
Require all granted
</Directory>
</VirtualHost>
# www.example2.com, port 443
<VirtualHost 2.2.2.2:443>
ServerName www.example2.com
ServerAlias example2.com
ErrorLog "logs/example2_443_error_log"
CustomLog "logs/example2_443_access_log" Combined
DocumentRoot "/home"
<Directory "/home">
allow from all
Options None
Require all granted
</Directory>
</VirtualHost>
Now some details, for port 80:
Do not use <VirtualHost *> as this for Apache means "all ports, all requets, use this VirtualHost!"
You can have many Virtualhosts. Apache will know which one to use based on the value of ServerName, and the URL it received.
If the URL received matches none of the port 80 VirtualHosts, it will use the first one from the top.
If you are on Apache 2.2, you have to add NameVirtualHost *:80 to activate that mechanism, Apache 2.4 does it automatically.
I put *:80 to tell Apache to accept port 80 requests from any IP address, since it can differentiate between the VirtualHosts by name.
For log files:
I always separate my logs, per Virtualhost. Trying to debug it all in 1 file is crazy.
It also allows you to apply different log levels to different domains without having the entire infra in debug for example.
For port 443, a bit more complicated:
As you noticed, when you ask for https://ANYDOMAIN/ it always uses the first one.
That is because Apache must first negotiate the cipher and certificates with the browser and then it will know which domain is asked for.
There is no equivalent to NameVirtualHost *:443 that will work.
So we must use another method of separating the two domains.
That is why in my config, I put <VirtualHost 1.1.1.1:443> and <VirtualHost 2.2.2.2:443>.
1.1.1.1 and 2.2.2.2 are fictional IP addresses. Change those to real IPs you have.
That way Apache will know that if he gets a request for https://www.example2.com it should use the second :443 VirtualHost because DNS resolves www.example2.com to IP 2.2.2.2.
But that implies that you can setup 2 IP addresses on your system.
Also, you will need 1 certificate per domain (or only 1 certificate which is valid for both using alt_names).
There is one method that will allow you to get this working for :443, that is SNI. Do some research on "Apache SNI SSL", you will see some explanations on that. But that is outside the scope of this answer :-)
Well I wound up contacting my hosting company for an additional IP address for $1.50/mo and they informed me that I'm supposed to get 2 anyway so I got one for free. After changing my DNS for the 2nd domain to the new IP address and configuring my server to be aware of the new IP address, the same problem kept happening. I tried rebooting and what not and spent a few more hours on the issue until finally somewhere I read that the problem could be due to not having a directory entry in my httpd.conf or ssl.conf file.
Sure enough there was one for the 80 port httpd.conf vhost entry but not for the 443 port so I dropped in the following entry within the vhost section for my example2 domain and boom problem solved:
allow from all
Options None
Require all granted

Adding SSL to Apache Server

We got our SSL certificate today, I'm trying to add the SSL certificate to the domain so that we can access the website through https however I'm running into problems.
We have an apache server running on windows.
The configuration works perfectly for port 80 however when I add port 443 to the config everything stops working.
The error I get when starting apache is
The requested operation has failed.
I have added the following line
Listen 443
below the line:
Listen 80
I have added the following VirtualHost config
<VirtualHost _default_:443>
DocumentRoot "c:/path/to/website"
ServerName example.com
ServerAlias example.com www.example.com
SSLEngine on
SSLCertificateFile "c:/path/to/cert/cert.crt"
SSLCertificateKeyFile "c:/path/to/cert/key.key"
SSLCACertificateFile "c:/path/to/cert/bundle.ca-bundle"
</VirtualHost>
However whenever I start the apache server after adding this, it doesn't start and I get an error.
I have commented out pieces of code and have narrowed the issue down to the Listen 443 line. Is there something I am not taking into consideration when adding this?
These are the last 3 lines in the error.log
[Thu Jun 08 18:15:31.909142 2017] [mpm_winnt:notice] [pid 66428:tid 712] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Thu Jun 08 18:15:47.209776 2017] [mpm_winnt:notice] [pid 67332:tid 620] AH00364: Child: All worker threads have exited.
[Thu Jun 08 18:15:48.067933 2017] [mpm_winnt:notice] [pid 66428:tid 712] AH00430: Parent: Child process exited successfully.
Edit
This is the response from running httpd.exe -e debug
(OS 10013)An attempt was made to access a socket in a way forbidden by its access permissions. : AH00072: make_sock: could not bind to address [::]:443
(OS 10013)An attempt was made to access a socket in a way forbidden by its access permissions. : AH00072: make_sock: could not bind to address 0.0.0.0:443
AH00451: no listening sockets available, shutting down
AH00015: Unable to open logs
I don't know how your httpd.conf file looks like, maybe you deleted/changed accidentaly some value.
The very first thing you need to do is to restore your httpd.conf file and start the service without the SSL configuration. Once it works you can proceed with this steps:
In a new file separate all your SSL settings, maybe a new file called httpd-ssl.conf is a good name.
After that, at the end of your main httpd.conf add this lines to include the new file:
# Secure (SSL/TLS) connections
Include conf/httpd-ssl.conf
This as good practice to avoid changing/deleting accidentally something in the main config and limitate the source of possible errors, you'll know any error will be related to the new file included.
Your new conf/httpd-ssl.conf should look something like this (standard setup):
# HTTPS port
Listen 443
<VirtualHost _default_:443>
# General setup for the virtual host
DocumentRoot "C:/your_httpd_path/htdocs"
ServerName www.example.com:443
ServerAdmin admin#example.com
ErrorLog "C:/your_httpd_path/logs/error.log"
TransferLog "C:/your_httpd_path/logs/access.log"
# SSL Engine Switch:
SSLEngine on
# Server Certificates:
SSLCertificateFile "c:/path/to/cert/cert.crt"
SSLCertificateKeyFile "c:/path/to/cert/key.key"
SSLCACertificateFile "c:/path/to/cert/bundle.ca-bundle"
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory "C:/your_httpd_path/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
CustomLog "C:/your_httpd_path/logs/ssl_request.log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>
Have you tried using httpd.exe -e debug? maybe we can find something useful in this mode.
UPDATE: Aha! you got an error! It could be a duplicated line somewhere with 443.
Could you check your files in notepad++ and search all the coincidences that match "443"? probably you already had 443 configured and you tried adding it again? You only need to have one line with:
Listen 443
Or maybe already running in that port? Check with:
netstat -na | findstr "443"
If you have something like:
TCP [::]:443 [::]:0 LISTENING
Then something else is running on your 443 port. Anyway, you can change your httpd conf and set any other port like 4443 i.e. or kill the process which is taking 443 now.

httpd not starting after installing certificate [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
i got a ssl cert and im running ubuntu
the domain.crt and domain.ca-bundle files and in the folder as specified but no matter what i keep getting these errors
[Sat Jul 27 06:35:00 2013] [error] Unable to configure verify locations for client authentication
[Sat Jul 27 06:35:00 2013] [error] SSL Library Error: 218570875 error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long
[Sat Jul 27 06:36:55 2013] [error] Server should be SSL-aware but has no certificate configured [Hint: SSLCertificateFile] (/etc/apache2/sites-enabled/default-ssl:2)
my port.conf is
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
NameVirtualHost *:443
Listen 443
</IfModule>
and my default-ssl is as follows
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster#localhost
ServerName www.domain.com
ServerAlias domain.com
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
-----------
---------------
-------------------- more configs
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
# A self-signed (snakeoil) certificate can be created by installing
# the ssl-cert package. See
# /usr/share/doc/apache2.2-common/README.Debian.gz for more info.
# If both key and certificate are stored in the same file, only the
# SSLCertificateFile directive is needed.
# SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateFile /etc/ssl/private/domain.crt
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
SSLCertificateChainFile /etc/ssl/private/domain.ca-bundle
Solution
I added these in /etc/apache2/apache2.conf
SSLCertificateFile your.crt
SSLCertificateKeyFile your.key
SSLCertificateChainFile your_bundle.crt
 Long part
There was some message when I enabled ssh in apache to read file /usr/share/doc/apache2.2-common/README.Debian.gz, it says:
6) Message "Server should be SSL-aware but has no certificate configured" in
error log
Since 2.2.12, Apache is stricter about certain misconfigurations concerning
name based SSL virtual hosts. See NEWS.Debian.gz for more details.
And NEWS says:
* The new support for TLS Server Name Indication added in 2.2.12 causes
Apache to be stricter about certain misconfigurations involving name
based SSL virtual hosts. This may result in Apache refusing to start
with the logged error message:
Server should be SSL-aware but has no certificate configured
[Hint: SSLCertificateFile]
Up to 2.2.11, Apache accepted configurations where the necessary SSL
configuration statements were included in the first (default)
<Virtualhost *:443> block but not in subsequent <Virtualhost *:443>
blocks. Starting with 2.2.12, every VirtualHost block used with SSL must
contain the SSLEngine, SSLCertificateFile, and SSLCertificateKeyFile
directives (SSLCertificateKeyFile is optional in some cases).
When you encounter the above problem, the output of the command
egrep -ir '^[^#]*(sslcertificate|sslengine|virtualhost)' \
/etc/apache2/*conf* /etc/apache2/*enabled
may be useful to determine which VirtualHost sections need to be changed.
There is more there.
You can try these for SSL certificate integration.
This should be under httpd.conf file under virtual host and please locate the virtual host section for the site that the SSL certificate will secure.
SSLCACertificateFile - This will need to point to the appropriate
to root CA certificate.
SSLCertificateChainFile - This will need to point to the appropriate
intermediate root CA certificates
SSLCertificateFile - This will need to point to the end entity
certificate (the one you have called "mydomain.crt")
SSLCertificateKeyFile – This will need to point to the private key file associated with your certificate.