21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

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

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

In a default configuration, PostgreSQLdoes not require clients to connect to the<br />

server with SSL; the use of SSL is strictly a client option. However, clients can be<br />

required to use SSL using the hostssl record format in the pg_hba.conf file.<br />

The PostgreSQLC API function PQconnectdb( ) requires that a conninfo object be<br />

filled in and passed to it to establish a connection to the server. One of the fields in<br />

the conninfo structure is an integer field called requiressl, which allows the client to<br />

decide whether SSLshould or should not be required for the connection. If this field<br />

is set to 1, the connection will fail if the server does not support SSL; otherwise, the<br />

use of SSLwill be negotiated as part of the connection handshake. In the latter case,<br />

SSLwill only be used if a hostssl record exists in pg_hba.conf requiring the use of<br />

SSL by clients.<br />

See Also<br />

Recipe 9.5<br />

9.11 Using a Virtual Private Network to Secure<br />

Network Connections<br />

<strong>Problem</strong><br />

Your program operates over a network and interacts with an existing network infrastructure<br />

that provides no support for secure communications such as SSL. You’re<br />

guaranteed that your program will be used only by a select group of people, and you<br />

need to secure its network traffic against sniffing and hijacking.<br />

Solution<br />

For this type of problem, using an SSLtunnel such as Stunnel is sufficient, but the<br />

certificate requirements and limited verification options provided by Stunnel may not<br />

provide everything you need. In addition, some network protocols do not lend themselves<br />

to SSLtunneling. (FTP is such a protocol because it may use random ports in<br />

both directions.) An alternate solution is to use a virtual private network (VPN) for<br />

the network services that your program needs.<br />

Discussion<br />

VPNs can be tricky to set up and get to work properly. There can be many interoperability<br />

problems across platforms, but VPNs provide a clean solution insofar as<br />

requiring fewer modifications to firewall rules (especially if there are many insecure<br />

network services involved), less deployment of tunneling software, and less ongoing<br />

490 | Chapter 9: Networking<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!