13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 7 ■ WORKING WITH APACHE4. The client sends back a random number encrypted with the server’s publickey. Only the client knows the number, and only the server can decrypt it,since decryption requires the server’s private key. This means that a maliciousthird party can’t get this number.5. The server and client use this random number to generate a key to use forencrypting the rest of the transaction. So, since the malicious third-party can’tget at the random number, they can’t get at the data that’s encrypted with thekey based on it.The aim of SSL (and modern web browsers) is to make this as straightforward as possible from theclient side. This recipe and the next one use Apache2 with mod_ssl to get this set up on the web serverside.See recipe 2-3 for how to create an SSL certificate, either self-signed (which is fine for testing or for alocal site) or signed by an external CA (a much better bet if you’re a reasonably large or public site). Thecommon name (CN) must be the same as the address of your web site; otherwise, the certificate won’tmatch, and users will receive a warning when connecting. Note that you can create your certificateeither with or without a passphrase. In theory, a passphrase increases server security. However, inpractice, if someone can read or copy the private key (and therefore need the passphrase), then theyalready have root-level access to the system and could obtain the passphrase, for example by using aprogram like keylogger. A passphrase will protect against script kiddies but not against a serious hacker.On the other hand, using a passphrase means that your web server won’t start unattended (forexample, automatically on boot or reboot), because the passphrase must be typed every time the webserver starts.■ Note You should not set a challenge password. (This is not the same thing as the passphrase!)To view your certificate, use the following:openssl -x509 -text -in server.crt■ Note Set up a diary reminder of the expiry date so that you can renew it when necessary! It’s embarrassingwhen your SSL suddenly stops working.When you have your certificate back from the CA, it’s best to rename it to my.domain.org.crt (to fitApache conventions and to allow for multiple domains with multiple certificates) and to rename the keyfile similarly. You should then verify the certificate:openssl verify -CAfile /path/to/trusted_ca.crt -purpose sslserver my.domain.org.crt163Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!