Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 2 > Installation/Configuration

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 13th July 2007, 12:26
nox171 nox171 is offline
Member
 
Join Date: Dec 2006
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default Secure a website with client-side ssl certification

Hi all,

I'm running ISPConfig on SUSE 10 installed following the perfect setup how to on this website.

I need to protect a connection to one of my website using a SSH Certificate.
I want to use a client-side certificate to authenticate only who really has the certificate installed in his pc.

I've found a couple of article (one and two for example) that describe how to do that.

Do you think I can apply them to an ISPConfig configuration?
I'm worried to edit something wrong in my box.

Is there anybody that have already done it?
Any suggestion on how to proceed??

Thanks!
Reply With Quote
Sponsored Links
  #2  
Old 14th July 2007, 13:07
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,735 Times in 2,571 Posts
Default

I haven't tried this, so I can't tell if it works.
But if you're worried about your current system, you could try it on a test system.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 20th July 2007, 16:39
nox171 nox171 is offline
Member
 
Join Date: Dec 2006
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm sweating hard to do that but so far so long something is working.
First I set up the testing machine totally similar to my live server
I've created my own CA and now I can provide new Certificate for my users.

At this point I need to hard redirect the traffic for my vhost to port 443 and enable SSL.

To do that I should edit, tell me if I'm wrong, this file:
/etc/apache2/vhosts.d/vhost-ssl.template and save it with somename.conf

Or edit httpd.conf ?
Or edit /etc/apache2/ssl-global.conf ??

Basically I'm following this tutorial . Look for point 4.

Help please!
Reply With Quote
  #4  
Old 20th July 2007, 17:03
nox171 nox171 is offline
Member
 
Join Date: Dec 2006
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Looking better I saw that httpd.conf include /etc/apache2/vhosts.d/*.conf

So now I'm trying to follow that white rabbit
Reply With Quote
  #5  
Old 20th July 2007, 18:41
nox171 nox171 is offline
Member
 
Join Date: Dec 2006
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok,
I've edited my personal file .conf in /etc/apache2/vhosts.d/

and here it is:
Code:
# Template for a VirtualHost with SSL
# Note: to use the template, rename it to /etc/apache2/vhost.d/yourvhost.conf.
# Files must have the .conf suffix to be loaded.
#
# See /usr/share/doc/packages/apache2/README.QUICKSTART for further hints
# about virtual hosts.

#
# This is the Apache server configuration file providing SSL support.
# It contains the configuration directives to instruct the server how to
# serve pages over an https connection. For detailing information about these 
# directives see <URL:http://httpd.apache.org/docs-2.0/mod/mod_ssl.html>
#
#   For the moment, see <URL:http://www.modssl.org/docs/> for this info. 
#   The documents are still being prepared from material donated by the
#   modssl project.
# 
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.  
#

#   Until documentation is completed, please check http://www.modssl.org/
#   for additional config examples and module docmentation.  Directives
#   and features of mod_ssl are largely unchanged from the mod_ssl project
#   for Apache 1.3.

<IfDefine SSL>
<IfDefine !NOSSL>

##
## SSL Virtual Host Context
##

<VirtualHost _default_:443>

	#  General setup for the virtual host
	DocumentRoot "/var/www/web1/web"
	#ServerName test.myhost.co.uk:443
	#ServerAdmin something...
	ErrorLog /var/log/apache2/error_log
	TransferLog /var/log/apache2/access_log

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

	#   SSL Cipher Suite:
	#   List the ciphers that the client is permitted to negotiate.
	#   See the mod_ssl documentation for a complete list.
	#SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

	#   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.  Keep
	#   in mind that if you have both an RSA and a DSA certificate you
	#   can configure both in parallel (to also allow the use of DSA
	#   ciphers, etc.)
	SSLCertificateFile /etc/ssl_mycompany/myCA/private/server-key-cert.pem
	#SSLCertificateFile /etc/apache2/ssl.crt/server-dsa.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/apache2/ssl.key/server.key
	#SSLCertificateKeyFile /etc/apache2/ssl.key/server-dsa.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/apache2/ssl.crt/ca.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)
	#   Note: Inside SSLCACertificatePath you need hash symlinks
	#         to point to the certificate files. Use the provided
	#         Makefile to update the hash symlinks after changes.
	#SSLCACertificatePath /etc/apache2/ssl.crt
	SSLCACertificateFile /etc/ssl_mycompany/myCA/certs/myca.crt

	#   Certificate Revocation Lists (CRL):
	#   Set the CA revocation path where to find CA CRLs for client
	#   authentication or alternatively one huge file containing all
	#   of them (file must be PEM encoded)
	#   Note: Inside SSLCARevocationPath you need hash symlinks
	#         to point to the certificate files. Use the provided
	#         Makefile to update the hash symlinks after changes.
	#SSLCARevocationPath /etc/apache2/ssl.crl
	#SSLCARevocationFile /etc/ssl_mycompany/myCA/crl/myca.crl

	#   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  1

	#   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 "my company Ltd" )
	#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 CompatEnvVars:
	#     This exports obsolete environment variables for backward compatibility
	#     to Apache-SSL 1.x, mod_ssl 2.0.x, Sioux 1.0 and Stronghold 2.x. Use this
	#     to provide compatibility to existing CGI scripts.
	#   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 +CompatEnvVars +StrictRequire
	
	CustomLog logs/ssl_request_log \
	"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

	<Files ~ "\.(cgi|shtml|phtml|php3?)$">
	    SSLOptions +StdEnvVars
	</Files>
	<Directory "/srv/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.
	SetEnvIf User-Agent ".*MSIE.*" \
		 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 /var/log/apache2/ssl_request_log   ssl_combined

</VirtualHost>                                  

</IfDefine>
</IfDefine>
But when I try to start Apache2 with SSH I've got this error:

Code:
test:/etc/apache2/vhosts # /etc/init.d/apache2 startssl
Starting httpd2 (prefork) startproc:  exit status of parent of /usr/sbin/httpd2-prefork: 1
                                                                      failed
Do you know why????

other question: do I have to enable the SSL option in ISPConfig for my website and import the server certificate I've created before?
Thanks!

Last edited by nox171; 20th July 2007 at 18:45.
Reply With Quote
  #6  
Old 21st July 2007, 18:34
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,735 Times in 2,571 Posts
Default

What's the output of
Code:
httpd -t
?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #7  
Old 22nd July 2007, 22:03
nox171 nox171 is offline
Member
 
Join Date: Dec 2006
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code:
test:/etc/apache2/vhosts.d # httpd -t
Syntax OK
Reply With Quote
  #8  
Old 23rd July 2007, 06:45
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,488
Thanks: 813
Thanked 5,259 Times in 4,123 Posts
Default

Thats fine so far. Do you get any errors in the apache error logfile?
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #9  
Old 23rd July 2007, 11:51
nox171 nox171 is offline
Member
 
Join Date: Dec 2006
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had got an error concerning the log file location.
It was looking for the SSL log in /srv/www/logs/ssl_request_log

I changed it to /var/www/log/apache2/ssl_request_log
Re-started apache with SSL and I had got a "done" output!

Now i've tried to access my website using SSL, I've also installed my cerficate in my broswer but I receive a:
Code:
Forbidden

You don't have permission to access / on this server.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
Looking at the logs:

/etc/log/apache2/error_log
Code:
[Mon Jul 23 10:38:21 2007] [error] [client 192.168.22.152] access to /usr/share/apache2/error/HTTP_FORBIDDEN.html.var failed, reason: SSL requirement expression not fulfilled (see SSL logfile for more details)
/var/log/apache2/ssl_request_log
Code:
[23/Jul/2007:10:50:30 +0100] 192.168.22.152 TLSv1 RC4-MD5 "GET /index.php HTTP/1.1" -
[23/Jul/2007:10:50:30 +0100] 192.168.22.152 TLSv1 RC4-MD5 "GET /index.php HTTP/1.1" - "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
now?
Reply With Quote
  #10  
Old 23rd July 2007, 13:34
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,735 Times in 2,571 Posts
 
Default

Quote:
Originally Posted by nox171
/etc/log/apache2/error_log
Code:
[Mon Jul 23 10:38:21 2007] [error] [client 192.168.22.152] access to /usr/share/apache2/error/HTTP_FORBIDDEN.html.var failed, reason: SSL requirement expression not fulfilled (see SSL logfile for more details)
What'S in Apache's SSL error log?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SSL for virtual hosts on one certificate rbartz Tips/Tricks/Mods 8 20th November 2007 17:59
now client associated with website Daisy Installation/Configuration 1 18th March 2007 12:17
change website client kaspars Installation/Configuration 1 13th March 2007 16:55
vsftp - 550 Failed to change directory latcarf Server Operation 8 14th May 2006 02:05
How do you set up client for SSL? heftigrat General 26 16th January 2006 15:31


All times are GMT +2. The time now is 01:45.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.