分类: 系统运维
2005-05-23 21:18:43
Here is a step-by-step description:
PATH
. But some commands even work ok when you just run the ``openssl
'' program from within the OpenSSL source tree as ``./apps/openssl
''.$ openssl genrsa -des3 -out server.key 1024
server.key
file and remember the pass-phrase you had to enter at a secure
location. You can see the details of this RSA private key via the
command:$ openssl rsa -noout -text -in server.key
$ openssl rsa -in server.key -out server.key.unsecure
$ openssl req -new -key server.key -out server.csr
, enter " here. You can see the details of this CSR via the command$ openssl req -noout -text -in server.csr
$ openssl x509 -noout -text -in server.crt
server.key
and server.crt
. These now can be used as following inside your Apache's httpd.conf
file: SSLCertificateFile /path/to/this/server.crtThe
SSLCertificateKeyFile /path/to/this/server.key
server.csr
file is no longer needed. The short answer is to use the CA.sh
or CA.pl
script provided by OpenSSL. The long and manual answer is this:
$ openssl genrsa -des3 -out ca.key 1024
ca.key
file and remember the pass-phrase you currently entered at a secure
location. You can see the details of this RSA private key via the
command$ openssl rsa -noout -text -in ca.key
$ openssl rsa -in ca.key -out ca.key.unsecure
$ openssl req -new -x509 -days 365 -key ca.key -out ca.crt
$ openssl x509 -noout -text -in ca.crt
openssl ca
'' command has some strange requirements and the default OpenSSL config doesn't allow one easily to use ``openssl ca
'' directly. So a script named sign.sh
is distributed with the mod_ssl distribution (subdir pkg.contrib/
). Use this script for signing.
server.csr
at hand):$ ./sign.sh server.csr
server.crt
file.You simply have to read it with the old pass-phrase and write it again by specifying the new pass-phrase. You can accomplish this with the following commands:
$ openssl rsa -des3 -in server.key -out server.key.new
$ mv server.key.new server.key
Here you're asked two times for a PEM pass-phrase. At the first prompt enter the old pass-phrase and at the second prompt enter the new pass-phrase.
The reason why this dialog pops up at startup and every re-start is that the RSA private key inside your server.key file is stored in encrypted format for security reasons. The pass-phrase is needed to be able to read and parse this file. When you can be sure that your server is secure enough you perform two steps:
$ cp server.key server.key.org
$ openssl rsa -in server.key.org -out server.key
$ chmod 400 server.key
Now server.key
will contain an unencrypted copy of the
key. If you point your server at this file it will not prompt you for a
pass-phrase. HOWEVER, if anyone gets this key they will be able to
impersonate you on the net. PLEASE make sure that the permissions on
that file are really such that only root or the web server user can
read it (preferably get your web server to start as root but run as
another server, and have the key readable only by root).
As an alternative approach you can use the ``SSLPassPhraseDialog exec:/path/to/program
'' facility. But keep in mind that this is neither more nor less secure, of course.