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.

if (our_ctx) *ctx = 0;<br />

return 0;<br />

}<br />

When a new socket connection is accepted, SSL_accept( ) is called to perform the<br />

SSLhandshake. The server’s certificate (and possibly its chain, depending on how<br />

you configure the spc_x509store_t object) is sent to the peer, and if a client certificate<br />

is requested and received, it will be verified. If the handshake is successful, the<br />

returned BIO object behaves exactly the same as the BIO object that is returned by<br />

spc_connect( ) or spc_connect_ssl( ). Regardless of whether a new connection was<br />

successfully established, the listening BIO object passed into SSL_accept( ) will be<br />

ready for another call to SSL_accept( ) to accept the next connection.<br />

See Also<br />

Recipes 9.1, 10.5<br />

9.3 Using Session Caching to Make SSL Servers<br />

More Efficient<br />

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

You have a client and server pair that speak SSLto each other. The same client often<br />

makes several connections to the same server in a short period of time. You need a<br />

way to speed up the process of the client’s reconnecting to the server without sacrificing<br />

security.<br />

Solution<br />

The terms SSL session and SSL connection are often confused or used interchangeably,<br />

but they are, in fact, two different things. An SSLsession refers to the set of<br />

parameters and encryption keys created by performing an SSLhandshake. An SSL<br />

connection is an active conversation between two peers that uses an SSLsession.<br />

Normally, when an SSLconnection is established, the handshake process negotiates<br />

the parameters that become a session. It is this negotiation that causes establishment<br />

of SSL connections to be such an expensive operation.<br />

Luckily, it is possible to cache sessions. Once a client has connected to the server and<br />

successfully completed the normal handshake process, both the client and the server<br />

can save the session parameters so that the next time the client connects to the<br />

server, it can simply reuse the session, thus avoiding the overhead of negotiating new<br />

parameters and encryption keys.<br />

460 | 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!