#include <bio.h>

Inheritance diagram for Ssl::ServerBio:
Collaboration diagram for Ssl::ServerBio:

Public Member Functions

 ServerBio (const int anFd)
 
virtual void stateChanged (const SSL *ssl, int where, int ret)
 The ServerBio version of the Ssl::Bio::stateChanged method. More...
 
virtual int write (const char *buf, int size, BIO *table)
 
virtual int read (char *buf, int size, BIO *table)
 
virtual void flush (BIO *table)
 
void setClientFeatures (Security::TlsDetails::Pointer const &details, SBuf const &hello)
 Sets the random number to use in client SSL HELLO message. More...
 
bool resumingSession ()
 
bool holdWrite () const
 The write hold state. More...
 
void holdWrite (bool h)
 Enables or disables the write hold state. More...
 
bool holdRead () const
 The read hold state. More...
 
void holdRead (bool h)
 Enables or disables the read hold state. More...
 
void recordInput (bool r)
 Enables or disables the input data recording, for internal analysis. More...
 
bool canSplice ()
 Whether we can splice or not the SSL stream. More...
 
bool canBump ()
 Whether we can bump or not the SSL stream. More...
 
void mode (Ssl::BumpMode m)
 The bumping mode. More...
 
Ssl::BumpMode bumpMode ()
 return the bumping mode More...
 
bool gotHello () const
 
bool gotHelloFailed () const
 Return true if the Server Hello parsing failed. More...
 
const Security::CertListserverCertificatesIfAny ()
 
const
Security::TlsDetails::Pointer
receivedHelloDetails () const
 
int fd () const
 The SSL socket descriptor. More...
 
const SBufrBufData ()
 The buffered input data. More...
 

Static Public Member Functions

static BIO * Create (const int fd, Security::Io::Type type)
 
static void Link (SSL *ssl, BIO *bio)
 Tells ssl connection to use BIO and monitor state via stateChanged() More...
 

Protected Attributes

const int fd_
 the SSL socket we are reading and writing More...
 
SBuf rbuf
 Used to buffer input data. More...
 

Private Member Functions

int readAndGive (char *buf, const int size, BIO *table)
 Read and give everything to OpenSSL. More...
 
int readAndParse (char *buf, const int size, BIO *table)
 
int readAndBuffer (BIO *table)
 
int giveBuffered (char *buf, const int size)
 

Private Attributes

Security::TlsDetails::Pointer clientTlsDetails
 SSL client features extracted from ClientHello message or SSL object. More...
 
SBuf clientSentHello
 TLS client hello message, used to adapt our tls Hello message to the server. More...
 
SBuf helloMsg
 Used to buffer output data. More...
 
mb_size_t helloMsgSize
 
bool helloBuild
 True if the client hello message sent to the server. More...
 
bool allowSplice
 True if the SSL stream can be spliced. More...
 
bool allowBump
 True if the SSL stream can be bumped. More...
 
bool holdWrite_
 The write hold state of the bio. More...
 
bool holdRead_
 The read hold state of the bio. More...
 
bool record_
 If true the input data recorded to rbuf for internal use. More...
 
bool parsedHandshake
 whether we are done parsing TLS Hello More...
 
bool parseError
 error while parsing server hello message More...
 
Ssl::BumpMode bumpMode_
 
size_t rbufConsumePos
 The size of data stored in rbuf which passed to the openSSL. More...
 
Security::HandshakeParser parser_
 The TLS/SSL messages parser. More...
 

Detailed Description

BIO node to handle socket IO for squid server side If bumping is enabled, analyses the SSL hello message sent by squid OpenSSL subsystem (step3 bumping step) against bumping mode:

  • Peek mode: Send client hello message instead of the openSSL generated hello message and normaly denies bumping and allow only splice or terminate the SSL connection
  • Stare mode: Sends the openSSL generated hello message and normaly denies splicing and allow bump or terminate the SSL connection If SQUID_USE_OPENSSL_HELLO_OVERWRITE_HACK is enabled also checks if the openSSL library features are compatible with the features reported in web client SSL hello message and if it is, overwrites the openSSL SSL object members to replace hello message with web client hello message. This is may allow bumping in peek mode and splicing in stare mode after the server hello message received.

Definition at line 120 of file bio.h.

Constructor & Destructor Documentation

Ssl::ServerBio::ServerBio ( const int  anFd)
explicit

Definition at line 245 of file bio.cc.

Member Function Documentation

Ssl::BumpMode Ssl::ServerBio::bumpMode ( )
inline

Definition at line 159 of file bio.h.

References bumpMode_.

bool Ssl::ServerBio::canBump ( )
inline

Definition at line 156 of file bio.h.

References allowBump.

bool Ssl::ServerBio::canSplice ( )
inline

Definition at line 154 of file bio.h.

References allowSplice.

BIO * Ssl::Bio::Create ( const int  fd,
Security::Io::Type  type 
)
staticinherited

Creates a low-level BIO table, creates a high-level Ssl::Bio object for a given socket, and then links the two together via BIO_C_SET_FD.

Definition at line 66 of file bio.cc.

References NULL, squid_bio_create(), squid_bio_ctrl(), squid_bio_destroy(), squid_bio_puts(), squid_bio_read(), squid_bio_write(), and SquidMethods.

Referenced by CreateSession().

int Ssl::Bio::fd ( ) const
inlineinherited

Definition at line 46 of file bio.h.

References Ssl::Bio::fd_.

Referenced by squid_bio_ctrl().

void Ssl::ServerBio::flush ( BIO *  table)
virtual

The ServerBio version of the Ssl::Bio::flush method. Flushes any buffered data

Reimplemented from Ssl::Bio.

Definition at line 547 of file bio.cc.

References Ssl::Bio::write().

int Ssl::ServerBio::giveBuffered ( char *  buf,
const int  size 
)
private

give previously buffered bytes to OpenSSL returns the number of bytes given

Definition at line 351 of file bio.cc.

References debugs.

bool Ssl::ServerBio::gotHello ( ) const
inline
Return values
trueif the Server hello message received

Definition at line 162 of file bio.h.

References parsedHandshake, and parseError.

bool Ssl::ServerBio::gotHelloFailed ( ) const
inline

Definition at line 165 of file bio.h.

References parsedHandshake, and parseError.

bool Ssl::ServerBio::holdRead ( ) const
inline

Definition at line 148 of file bio.h.

References holdRead_.

Referenced by Security::PeerConnector::noteWantRead().

void Ssl::ServerBio::holdRead ( bool  h)
inline

Definition at line 150 of file bio.h.

References holdRead_.

bool Ssl::ServerBio::holdWrite ( ) const
inline

Definition at line 144 of file bio.h.

References holdWrite_.

void Ssl::ServerBio::holdWrite ( bool  h)
inline

Definition at line 146 of file bio.h.

References holdWrite_.

void Ssl::Bio::Link ( SSL *  ssl,
BIO *  bio 
)
staticinherited

Definition at line 92 of file bio.cc.

References squid_ssl_info().

Referenced by CreateSession().

void Ssl::ServerBio::mode ( Ssl::BumpMode  m)
inline

Definition at line 158 of file bio.h.

References bumpMode_.

const SBuf& Ssl::Bio::rBufData ( )
inlineinherited

Definition at line 58 of file bio.h.

References Ssl::Bio::rbuf.

Referenced by Ssl::PeekingPeerConnector::initialize(), and switchToTunnel().

int Ssl::ServerBio::read ( char *  buf,
int  size,
BIO *  table 
)
virtual

The ServerBio version of the Ssl::Bio::read method If the record flag is set then append the data to the rbuf member

Reimplemented from Ssl::Bio.

Definition at line 275 of file bio.cc.

int Ssl::ServerBio::readAndBuffer ( BIO *  table)
private

Reads more data into the read buffer. Returns either the number of bytes read or, on errors (including "try again" errors), a negative number.

Definition at line 337 of file bio.cc.

References Ssl::Bio::read().

int Ssl::ServerBio::readAndGive ( char *  buf,
const int  size,
BIO *  table 
)
private

Definition at line 285 of file bio.cc.

References Ssl::Bio::read().

int Ssl::ServerBio::readAndParse ( char *  buf,
const int  size,
BIO *  table 
)
private

Read and give everything to our parser. When/if parsing is finished (successfully or not), start giving to OpenSSL.

Definition at line 305 of file bio.cc.

References debugs.

const Security::TlsDetails::Pointer& Ssl::ServerBio::receivedHelloDetails ( ) const
inline
Returns
the TLS Details advertised by TLS server.

Definition at line 171 of file bio.h.

References Security::HandshakeParser::details, and parser_.

void Ssl::ServerBio::recordInput ( bool  r)
inline

Definition at line 152 of file bio.h.

References record_.

bool Ssl::ServerBio::resumingSession ( )

Definition at line 556 of file bio.cc.

const Security::CertList& Ssl::ServerBio::serverCertificatesIfAny ( )
inline
Returns
the server certificates list if received and parsed correctly

Definition at line 168 of file bio.h.

References parser_, and Security::HandshakeParser::serverCertificates.

void Ssl::ServerBio::setClientFeatures ( Security::TlsDetails::Pointer const &  details,
SBuf const &  hello 
)

Definition at line 268 of file bio.cc.

void Ssl::ServerBio::stateChanged ( const SSL *  ssl,
int  where,
int  ret 
)
virtual

Reimplemented from Ssl::Bio.

Definition at line 262 of file bio.cc.

References Ssl::Bio::stateChanged().

int Ssl::ServerBio::write ( const char *  buf,
int  size,
BIO *  table 
)
virtual

The ServerBio version of the Ssl::Bio::write method If a clientRandom number is set then rewrites the raw hello message "client random" field with the provided random number. It may buffer the output packets.

Reimplemented from Ssl::Bio.

Definition at line 471 of file bio.cc.

References adjustSSL(), assert, Ssl::bumpPeek, Ssl::bumpStare, debugs, fd_table, Must, size, and Ssl::Bio::write().

Member Data Documentation

bool Ssl::ServerBio::allowBump
private

Definition at line 187 of file bio.h.

Referenced by canBump().

bool Ssl::ServerBio::allowSplice
private

Definition at line 186 of file bio.h.

Referenced by canSplice().

Ssl::BumpMode Ssl::ServerBio::bumpMode_
private

Definition at line 193 of file bio.h.

Referenced by bumpMode(), and mode().

SBuf Ssl::ServerBio::clientSentHello
private

Definition at line 182 of file bio.h.

Security::TlsDetails::Pointer Ssl::ServerBio::clientTlsDetails
private

Definition at line 180 of file bio.h.

const int Ssl::Bio::fd_
protectedinherited

Definition at line 60 of file bio.h.

Referenced by Ssl::Bio::Bio(), and Ssl::Bio::fd().

bool Ssl::ServerBio::helloBuild
private

Definition at line 185 of file bio.h.

SBuf Ssl::ServerBio::helloMsg
private

Definition at line 183 of file bio.h.

mb_size_t Ssl::ServerBio::helloMsgSize
private

Definition at line 184 of file bio.h.

bool Ssl::ServerBio::holdRead_
private

Definition at line 189 of file bio.h.

Referenced by holdRead().

bool Ssl::ServerBio::holdWrite_
private

Definition at line 188 of file bio.h.

Referenced by holdWrite().

bool Ssl::ServerBio::parsedHandshake
private

Definition at line 191 of file bio.h.

Referenced by gotHello(), and gotHelloFailed().

bool Ssl::ServerBio::parseError
private

Definition at line 192 of file bio.h.

Referenced by gotHello(), and gotHelloFailed().

Security::HandshakeParser Ssl::ServerBio::parser_
private

Definition at line 197 of file bio.h.

Referenced by receivedHelloDetails(), and serverCertificatesIfAny().

SBuf Ssl::Bio::rbuf
protectedinherited

Definition at line 61 of file bio.h.

Referenced by Ssl::Bio::rBufData(), and Ssl::ClientBio::setReadBufData().

size_t Ssl::ServerBio::rbufConsumePos
private

Definition at line 196 of file bio.h.

bool Ssl::ServerBio::record_
private

Definition at line 190 of file bio.h.

Referenced by recordInput().


The documentation for this class was generated from the following files:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors