21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

attempt to develop and debug SSL-enabled clients and servers together from the<br />

ground up, especially if you do not have any prior experience programming with<br />

SSL. Stunnel will help you debug your SSL code.<br />

A Stunnel configuration file is organized in sections. Each section contains a set of<br />

keys, and each key has an associated value. Sections and keys are both named and<br />

case-insensitive. A configuration file is parsed from top to bottom with sections<br />

delimited by a line containing the name of the section surrounded by square brackets.<br />

The other lines contain key and value pairs that belong to the most recently<br />

parsed section delimiter. In addition, an optional global section that is unnamed<br />

occurs before the first named section in the file. Keys are separated from their associated<br />

value by an equal sign (=).<br />

Comments may only begin at the start of a line that begins with a hash mark (#)<br />

(optionally preceded by whitespace), and the whole line is treated as a comment.<br />

Any leading or trailing whitespace surrounding a key or a value is stripped. Any<br />

other whitespace is significant, including leading or trailing whitespace surrounding<br />

a section name (as it would occur between the square brackets). For example, “[ my_<br />

section ]” is not the same as “[my_section]”. The documentation included with Stunnel<br />

describes the supported keys sufficiently well, so we won’t duplicate it here.<br />

One nice advantage of the configuration files over the old command-line interface is<br />

that each section in the configuration file defines either a client or a server, so a single<br />

instance of Stunnel can be used to run multiple clients or servers. If you want to<br />

run both clients and servers, you still need two instances of Stunnel running because<br />

the flag that determines which mode to run in is a global option. With the command-line<br />

interface, multiple instances of Stunnel used to be required, one for each<br />

client or server that you wanted to run. Therefore, if you wanted to use Stunnel for<br />

POP3, IMAP, and SMTPS servers, you needed to run three instances of Stunnel.<br />

Each section name defines the name of the service that will be used with TCP Wrappers<br />

and for logging purposes. For both clients and servers, specify the accept and<br />

connect keys. The accept key specifies the port on which Stunnel will listen for<br />

incoming connections, and the connect key specifies the port that Stunnel will<br />

attempt to connect to for outgoing connections. At a minimum, these two keys must<br />

specify a port number, but they may also optionally include a hostname or IP<br />

address. To include a hostname or IP address, precede the port number with the<br />

hostname or IP address, and separate the two with a colon (:).<br />

You enable the mode for Stunnel as follows:<br />

Server mode<br />

To enable server mode, set the global option key client to no. When running in<br />

server mode, Stunnel expects incoming connections to speak SSLand makes<br />

outgoing connections without SSL. You will also need to set the two global<br />

options cert and key to the names of files containing the certificate and key to<br />

use.<br />

Enabling SSL without Modifying Source Code | 469<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

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

Saved successfully!

Ooh no, something went wrong!