13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Using Secure Sockets Layer (SSL)<br />

413<br />

If installation <strong>and</strong> configuration are part of your role, you do need to worry about the<br />

way software is installed <strong>and</strong> configured. Many mistakes made in security are a result of<br />

not following the warnings in the documentation or involve general system administration<br />

issues that are topics for another book.We suggest you buy a good book on administering<br />

the operating system you intend to use or hire an expert system administrator.<br />

One specific issue to consider when installing <strong>PHP</strong> is that installing <strong>PHP</strong> as a SAPI<br />

module for your web server is generally more secure, as well as much more efficient,<br />

than running it via the CGI interface.<br />

The primary point you need to worry about as a web application developer is what<br />

your own scripts do or not do.What potentially sensitive data does your application<br />

transmit to the user over the Internet? What sensitive data do you ask users to transmit<br />

to you? If you are transmitting information that should be a private transaction between<br />

you <strong>and</strong> your users or that should be difficult for an intermediary to modify, you should<br />

consider using SSL.<br />

We already discussed using SSL between the user’s computer <strong>and</strong> the server.You<br />

should also think about the situation in which you are transmitting data from one component<br />

of your system to another over a network. A typical example arises when your<br />

<strong>MySQL</strong> database resides on a different machine from your web server. <strong>PHP</strong> connects to<br />

your <strong>MySQL</strong> server via TCP/IP, <strong>and</strong> this connection is unencrypted. If these machines<br />

are both on a private local area network, you need to ensure that the network is secure.<br />

If the machines are communicating via the Internet, your system will probably run slowly,<br />

<strong>and</strong> you need to treat this connection in the same way as other connections over the<br />

Internet.<br />

It is important that when your users think they are dealing with you, they are, in fact,<br />

dealing with you. Registering for a digital certificate protects your visitors from spoofing<br />

(someone else impersonating your site), allows you to use SSL without users seeing a<br />

warning message, <strong>and</strong> provides an air of respectability to your online venture.<br />

Do your scripts carefully check the data that users enter? Are you careful about storing<br />

information securely? We answer these questions in the next few sections of this<br />

chapter.<br />

Using Secure Sockets Layer (SSL)<br />

The Secure Sockets Layer protocol suite was originally designed by Netscape to facilitate<br />

secure communication between web servers <strong>and</strong> web browsers. It has since been adopted as<br />

the unofficial st<strong>and</strong>ard method for browsers <strong>and</strong> servers to exchange sensitive information.<br />

Both SSL versions 2 <strong>and</strong> 3 are well supported. Most web servers either include SSL<br />

functionality or can accept it as an add-on module. Internet Explorer <strong>and</strong> Firefox have<br />

both supported SSL from version 3.<br />

Networking protocols <strong>and</strong> the software that implements them are usually arranged as<br />

a stack of layers. Each layer can pass data to the layer above or below <strong>and</strong> request services<br />

of the layer above or below. Figure 18.2 shows such a protocol stack.

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

Saved successfully!

Ooh no, something went wrong!