9#ifndef SQUID_SRC_SSL_BIO_H
10#define SQUID_SRC_SSL_BIO_H
24#include <openssl/bio.h>
36 explicit Bio(
const int anFd);
40 virtual int write(
const char *buf,
int size, BIO *table);
43 virtual int read(
char *buf,
int size, BIO *table);
53 virtual void stateChanged(
const SSL *ssl,
int where,
int ret);
59 static void Link(SSL *ssl, BIO *bio);
78 void stateChanged(
const SSL *ssl,
int where,
int ret)
override;
80 int write(
const char *buf,
int size, BIO *table)
override;
84 int read(
char *buf,
int size, BIO *table)
override;
128 void stateChanged(
const SSL *ssl,
int where,
int ret)
override;
133 int write(
const char *buf,
int size, BIO *table)
override;
136 int read(
char *buf,
int size, BIO *table)
override;
139 void flush(BIO *table)
override;
void applyTlsDetailsToSSL(SSL *ssl, Security::TlsDetails::Pointer const &details, Ssl::BumpMode bumpMode)
Counts events, forgetting old ones. Useful for "3 errors/minute" limits.
Incremental TLS/SSL Handshake parser.
TlsDetails::Pointer details
TLS handshake meta info. Never nil.
BIO source and sink node, handling socket I/O and monitoring SSL state.
int fd() const
The SSL socket descriptor.
const int fd_
the SSL socket we are reading and writing
SBuf rbuf
Used to buffer input data.
virtual void stateChanged(const SSL *ssl, int where, int ret)
virtual int write(const char *buf, int size, BIO *table)
Writes the given data to socket.
static void Link(SSL *ssl, BIO *bio)
Tells ssl connection to use BIO and monitor state via stateChanged()
static BIO * Create(const int fd, Security::Io::Type type)
virtual void flush(BIO *)
virtual int read(char *buf, int size, BIO *table)
Reads data from socket.
const SBuf & rBufData()
The buffered input data.
FadingCounter renegotiations
client requested renegotiations limit control
int write(const char *buf, int size, BIO *table) override
The ClientBio version of the Ssl::Bio::write method.
void stateChanged(const SSL *ssl, int where, int ret) override
bool holdRead_
The read hold state of the bio.
void setReadBufData(SBuf &data)
const char * abortReason
why we should terminate the connection during next TLS operation (or nil)
void hold(bool h)
Prevents or allow writing on socket.
bool holdWrite_
The write hold state of the bio.
static const int RenegotiationsLimit
the maximum tolerated number of client-initiated renegotiations in RenegotiationsWindow
int read(char *buf, int size, BIO *table) override
static const time_t RenegotiationsWindow
approximate size of a time window for computing client-initiated renegotiation rate (in seconds)
bool record_
If true the input data recorded to rbuf for internal use.
void mode(Ssl::BumpMode m)
The bumping mode.
int write(const char *buf, int size, BIO *table) override
SBuf helloMsg
Used to buffer output data.
void flush(BIO *table) override
bool allowBump
True if the SSL stream can be bumped.
Security::TlsDetails::Pointer clientTlsDetails
SSL client features extracted from ClientHello message or SSL object.
bool parsedHandshake
whether we are done parsing TLS Hello
SBuf clientSentHello
TLS client hello message, used to adapt our tls Hello message to the server.
size_t rbufConsumePos
The size of data stored in rbuf which passed to the openSSL.
bool holdWrite() const
The write hold state.
Security::HandshakeParser parser_
The TLS/SSL messages parser.
void recordInput(bool r)
Enables or disables the input data recording, for internal analysis.
bool canBump()
Whether we can bump or not the SSL stream.
bool gotHelloFailed() const
Return true if the Server Hello parsing failed.
void setClientFeatures(Security::TlsDetails::Pointer const &details, SBuf const &hello)
Sets the random number to use in client SSL HELLO message.
void stateChanged(const SSL *ssl, int where, int ret) override
The ServerBio version of the Ssl::Bio::stateChanged method.
bool encryptedCertificates() const
Ssl::BumpMode bumpMode()
return the bumping mode
bool holdWrite_
The write hold state of the bio.
const Security::TlsDetails::Pointer & receivedHelloDetails() const
int readAndParse(char *buf, const int size, BIO *table)
bool allowSplice
True if the SSL stream can be spliced.
void holdWrite(bool h)
Enables or disables the write hold state.
bool canSplice()
Whether we can splice or not the SSL stream.
int read(char *buf, int size, BIO *table) override
int readAndGive(char *buf, const int size, BIO *table)
Read and give everything to OpenSSL.
int readAndBuffer(BIO *table)
bool parseError
error while parsing server hello message
int giveBuffered(char *buf, const int size)
bool helloBuild
True if the client hello message sent to the server.