setup upd upd install -G -c openssl setup opensslThen there are several steps to create a key for a webserver. If you have multiple webservers, each on their own IP, you should create a separate key for each one.
If you have multiple webservers on one IP, (i.e. via NamedVirtualHost directives, etc.) you need to make one for that group of webserver, with a Common Name (see below) that matches all of them; for example if you have fred1.fnal.gov, fred2.fnal.gov and fred3.fnal.gov you could use a Common Name of "fred[123].fnal.gov" which would match all three (as a "glob" pattern, as in it would match them if they were filenames).
[For this section you want a copy of simple.cnf if you're going to get a DOEGrid signed certificate; otherwise you can omit the "-config simple.cnf" arguments, below.]
I reccomend if your webserver has config files in /foo/bar/conf that you do this stuff in /foo/bar/cert.
openssl req -config simple.cnf -new > new.cert.csr(If you get an error about random number seeding, you can do:
openssl rand -rand /tmp/ps_data 100 > /dev/nullto get the random number seed setup, and then retry...),
It will ask you several questions to fill out the request.
The main thing to remember here is that the "Common Name" in the request needs to be the name of the webserver, or (i.e the name part in http://name:port/whatever).
This looks something like:
openssl req -config simple.cnf -new > new.cert.csr Using configuration from /fnal/ups/prd/openssl/v0_8_0/SunOS-5/lib/openssl.cnf Generating a 1024 bit RSA private key .........+++++ ....+++++ writing new private key to 'privkey.pem' Enter PEM pass phrase: pick something Verifying password - Enter PEM pass phrase: pick something ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:US State or Province Name (full name) [Some-State]:Illinois Locality Name (eg, city) []:Batavia Organization Name (eg, company) [Internet Widgits Pty Ltd]:Fermilab Organizational Unit Name (eg, section) []:Operating System Support Department Common Name (eg, YOUR name) []:www-oss.fnal.gov Email Address []:mengel@fnal.gov Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []:
If you need to make a more complicated Certificate Signature Request (i.e. one good for several virtual hosts), it can be helpful to rename and update "simple.conf" file, and pass it to the "openssl req" command above, to make sure you get everything spelled right, etc. Saving that .conf file in the same directory with the other files makes it easy to use again. For example, this file is setup for two virtual hosts, and with the right answers for other questions filled in as the default -- currently doing 2 virtual hosts takes 3 Common Names, with the first being a wildcard matching the other 4 (which Netscape, and Mozilla will use) and the later 4 will be used by Internet Explorer to match the multiple virtual hosts. To use such a file, just do
openssl req -config ./multi.cnf -new > new.cert.csrand you can just hit return at all the prompts to make the new request. (Note: you may be tempted to try to change the commonNameMax values to a longer length to make a bigger wildcard; this won't actually work...)
openssl rsa -in privkey.pem -out new.cert.key
openssl x509 -in new.cert.csr -out new.cert.cert -req -signkey new.cert.key -days 365 -set_serial 2
Signature ok
subject=/C=US/ST=Illinois/L=Batavia/O=Fermilab/OU=Operating System Support
Department/CN=www-oss.fnal.gov/Email=mengel@fnal.gov
Getting Private key
Note the recently added '-set_serial' flag -- recent versions of Firefox complain if a site's
self-signed certificate is updated but has the same serial number as it used to. So set the
serial number higher than last time each time you sign a certificate.
SSLCertificateFile /path/to/certs/new.cert.cert SSLCertificateKeyFile /path/to/certs/new.cert.key
Listen my-server.fnal.gov:80 Listen my-server.fnal.gov:443 <VirtualHost my-server.fnal.gov:80> SSLDisable Include conf/srm.conf Include conf/access.conf </VirtualHost> <VirtualHost my-server.fnal.gov:443> # this is SSLEnable in apache 1.x SSLEngine on SSLVerifyDepth 10 SSLCertificateFile /fnal/www/cert/new.cert.cert SSLCertificateKeyFile /fnal/www/cert/new.cert.key Include conf/srm.conf Include conf/access.conf </VirtualHost>
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]+$/
For details, see the
mod_ssl reference manual
.
SSLCACertificatePath /fnal/www/cert/TrustedCAs
Remove any "SSLVerifyClient 0" lines in your httpd.conf files from
older, apache-ssl implementations.
SSLRequireSSL
SSLVerifyClient optional
SSLOptions +StdEnvVars
SSLRequire %{SSL_CLIENT_S_DN} =~ m/:(dane|mengel|schmidt)$/ && \
%{SSL_CLIENT_I_DN} eq \
"/DC=gov/DC=fnal/O=Fermilab/OU=Certificate Authorities/CN=Kerberized CA HSM"
More information is avaliable at
http://www.modssl.org/.