Linux+apache+openssl
Implementing HTTPS authentication apache2.0 HTTPS
Install SSL first, then compile and install Apache, then configure the certificate
1. Download Apache and OpenSSL
Url:
http://www.apache.org
http://www.openssl.org
2. Unzip
#tar ZXVF httpd-2.0.54.tar.gz
#tar ZXVF openssl-0.9.7g.tar.gz
3. Compile and install OpenSSL,
This software is primarily used to generate certificates:
#cd openssl-0.9.7g
#./config
#make
#make Test
#make Install
Put OpenSSL in the kernel directory so that it can run under any directory.
#cd/usr/local/bin
#ln-S/usr/local/ssl/bin/openssl OpenSSL
4. Compiling the installation
Apache
#cd/opt/httpd-2.0.54
#./configure--prefix= "/opt/apache2"--enable-so--enable-ssl
--with-ssl= "/usr/local/ssl/bin"
#make
#make Install
5. After installation, generate the certificate:
Create a Ssl.key directory under/opt/apache2/conf
#cd: /apache2/
#cd conf/
#mkdir Ssl.key
Then generate the certificate under this directory:
#cd ssl.key/
Generate the server private key:
#openssl Genrsa-des3-out Server.key 1024
Generating RSA private key, 1024x768 bit long modulus
.......................++++++
.................................................++++++
E is 65537 (0x10001)
Enter Pass phrase for Server.key:
Verifying-enter Pass phrase for Server.key:
Generate the server certificate request and fill in the relevant certificate information as required:
#openssl Req-new-key server.key-out SERVER.CSR
Enter Pass phrase for Server.key:
You is about to being asked to enter information that'll be incorporated into your certificate request.
What's about-to-enter is called a distinguished Name or a DN.
There is quite a few fields but can leave some blank
For some fields there would be a default value,
If you enter '. ', the field would be a left blank.
-----
Country Name (2 letter code) [AU]:
State or province name (full name) [Some-state]:
Locality Name (eg, city) []:tyl
Organization Name (eg, company) [Internet widgits Pty Ltd]:tz
Organizational Unit Name (eg, section) []:tz
Common name (eg, YOUR name) []:tyl
Email Address []:[email protected]
Please enter the following ' extra ' attributes
To is sent with your certificate request
A Challenge Password []:
An optional company name []:
Visa:
# OpenSSL x509-req-days 700-in server.csr-signkey server.key-out
Server.crt
Signature OK
Subject=/c=au/st=some-state/l=tyl/o=tz/ou=tz/cn=tyl/emailaddress=tan
[Email protected]
Getting Private Key
Enter Pass phrase for Server.key:
For security, and then we set the permissions for these files to 400.
chmod Server.key
chmod Server.cert
Finally to
/opt/apache2/conf/ssl.conf
To modify:
Vi/opt/apache2/conf/ssl.conf
The changes are in the following places:
#SSLCertificateFile/OPT/APACHE2/CONF/SSL.CRT/SERVER.CRT #108行
Sslcertificatefile/opt/apache2/conf/ssl.key/server.cert
#SSLCertificateFile/OPT/APACHE2/CONF/SSL.CRT/SERVER-DSA.CRT
Sslcertificatekeyfile/opt/apache2/conf/ssl.key/server.key #116行
#SSLCertificateKeyFile/opt/apache2/conf/ssl.key/server-dsa.key
So we're basically good with SSL.
Now let's get Apache to start SSL.
/opt/apache2/bin/apachectl start
Then ask for a certificate password, enter it correctly, and start with Apache together
Enter in the browser: https://localhost request to download the certificate, ok~ good ~ ~ it is so simple.