Client Certificate Authentication With Apache (An Example) |
(Last modified: 07/15/01)
Note that in a production environment, the CA should be a separate machine and disconnected from the network.
mkdir -p /etc/ssl/ca/private chown -R root:wheel /etc/ssl/ca chmod 700 /etc/ssl/ca/private
Next, generate a private key and a certificate request, and then self-sign the certificate.
openssl genrsa -out ca.key 1024 openssl req -new -key ca.key -out ca.csr openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt
openssl genrsa -out server.key 1024 openssl req -new -key server.key -out server.csr openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Make sure the path(s) to the server certificate are correct in /var/www/conf/httpd.conf.
Tell the web server (Apache) where it can find the CA certificate, in httpd.conf:
<VirtualHost _default_:443> ... SSLCACertificateFile /var/www/conf/ssl.crt/ca.crt ... </VirtualHost>
<VirtualHost _default_:443> ... <Location /cert> SSLRequireSSL SSLVerifyClient require SSLVerifyDepth 10 </Location> ... </VirtualHost>
Shutdown and Restart httpd:
apachectl stop /usr/sbin/httpd -DSSL
openssl genrsa -out client.key 1024 openssl req -new -key client.key -out client.csr -config openssl.cnfOpenSSL for Win32 can be downloaded here.
Note that OpenSSL won't be able to obtain a nice pseudo-random sample for its key generation, and will complain. However, it will allow you to specify a document for added entropy with the -rand switch. In testing, I created a file on the OpenBSD machine with dd if=/dev/srandom of=output.txt bs=4096 count=1, copied that file to Windows, and generated a key with openssl genrsa -rand output.txt -out client.key 1024.
openssl x509 -req -days 365 -CA ca.crt -CAkey ca.key -CAcreateserial -in client.csr -out client.crt
Copy the signed certificate (client.crt) back to the client.
openssl pkcs12 -export -clcerts -in client.crt -inkey client.key -out client.p12Double click client.p12 to import, and select the default values.
Finally, attempt to access the protected server pages (e.g. http://www.server.com/cert/).
mod_ssl homepage:
Public-Key Cryptography Standards:
http://www.rsasecurity.com/rsalabs/pkcs/
X-series Recommendations: X.500 and up:
http://www.itu.int//itudoc/itu-t/rec/x/x500up/
http://www.apacheweek.com/features/crl
Using Client Certificates with stunnel:
http://www.stunnel.org/faq/certs.html#ToC1
Copyright (c) 2001 Robert Mooney, All rights reserved.
This document may be freely distributed and modified, so long as the original author is credited.
If you are inclined, you can leave me a tip with PayPal. Sign up for it.
Return to the Main index |