proxygen
folly::RenegotiatingServer Class Reference

#include <AsyncSSLSocketTest.h>

Inheritance diagram for folly::RenegotiatingServer:
folly::AsyncSSLSocket::HandshakeCB folly::AsyncReader::ReadCallback

Public Member Functions

 RenegotiatingServer (AsyncSSLSocket::UniquePtr socket)
 
 ~RenegotiatingServer () override
 
void handshakeSuc (AsyncSSLSocket *) noexceptoverride
 
void handshakeErr (AsyncSSLSocket *, const AsyncSocketException &ex) noexceptoverride
 
void getReadBuffer (void **bufReturn, size_t *lenReturn) override
 
void readDataAvailable (size_t) noexceptoverride
 
void readEOF () noexceptoverride
 
void readErr (const AsyncSocketException &ex) noexceptoverride
 
- Public Member Functions inherited from folly::AsyncSSLSocket::HandshakeCB
virtual ~HandshakeCB ()=default
 
virtual bool handshakeVer (AsyncSSLSocket *, bool preverifyOk, X509_STORE_CTX *) noexcept
 
- Public Member Functions inherited from folly::AsyncReader::ReadCallback
virtual ~ReadCallback ()=default
 
virtual bool isBufferMovable () noexcept
 
virtual size_t maxBufferSize () const
 
virtual void readBufferAvailable (std::unique_ptr< IOBuf >) noexcept
 

Public Attributes

AsyncSSLSocket::UniquePtr socket_
 
unsigned char buf [128]
 
bool renegotiationError_ {false}
 

Detailed Description

Definition at line 986 of file AsyncSSLSocketTest.h.

Constructor & Destructor Documentation

folly::RenegotiatingServer::RenegotiatingServer ( AsyncSSLSocket::UniquePtr  socket)
inlineexplicit

Definition at line 989 of file AsyncSSLSocketTest.h.

References folly::SendMsgParamsCallbackBase::socket_.

990  : socket_(std::move(socket)) {
991  socket_->sslAccept(this);
992  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
NetworkSocket socket(int af, int type, int protocol)
Definition: NetOps.cpp:412
AsyncSSLSocket::UniquePtr socket_
folly::RenegotiatingServer::~RenegotiatingServer ( )
inlineoverride

Definition at line 994 of file AsyncSSLSocketTest.h.

References folly::SendMsgParamsCallbackBase::socket_.

994  {
995  socket_->setReadCB(nullptr);
996  }
AsyncSSLSocket::UniquePtr socket_

Member Function Documentation

void folly::RenegotiatingServer::getReadBuffer ( void **  bufReturn,
size_t *  lenReturn 
)
inlineoverridevirtual

When data becomes available, getReadBuffer() will be invoked to get the buffer into which data should be read.

This method allows the ReadCallback to delay buffer allocation until data becomes available. This allows applications to manage large numbers of idle connections, without having to maintain a separate read buffer for each idle connection.

It is possible that in some cases, getReadBuffer() may be called multiple times before readDataAvailable() is invoked. In this case, the data will be written to the buffer returned from the most recent call to readDataAvailable(). If the previous calls to readDataAvailable() returned different buffers, the ReadCallback is responsible for ensuring that they are not leaked.

If getReadBuffer() throws an exception, returns a nullptr buffer, or returns a 0 length, the ReadCallback will be uninstalled and its readError() method will be invoked.

getReadBuffer() is not allowed to change the transport state before it returns. (For example, it should never uninstall the read callback, or set a different read callback.)

Parameters
bufReturngetReadBuffer() should update *bufReturn to contain the address of the read buffer. This parameter will never be nullptr.
lenReturngetReadBuffer() should update *lenReturn to contain the maximum number of bytes that may be written to the read buffer. This parameter will never be nullptr.

Implements folly::AsyncReader::ReadCallback.

Definition at line 1007 of file AsyncSSLSocketTest.h.

1007  {
1008  *lenReturn = sizeof(buf);
1009  *bufReturn = buf;
1010  }
void folly::RenegotiatingServer::handshakeErr ( AsyncSSLSocket sock,
const AsyncSocketException ex 
)
inlineoverridevirtualnoexcept

handshakeErr() is called if an error occurs while establishing the SSL connection.

The HandshakeCB will be uninstalled before handshakeErr() is called.

Parameters
sockSSL socket on which the handshake was initiated
exAn exception representing the error.

Implements folly::AsyncSSLSocket::HandshakeCB.

Definition at line 1002 of file AsyncSSLSocketTest.h.

References ADD_FAILURE.

1004  {
1005  ADD_FAILURE() << "Renegotiating server handshake error: " << ex.what();
1006  }
#define ADD_FAILURE()
Definition: gtest.h:1808
void folly::RenegotiatingServer::handshakeSuc ( AsyncSSLSocket sock)
inlineoverridevirtualnoexcept

handshakeSuc() is called when a new SSL connection is established, i.e., after SSL_accept/connect() returns successfully.

The HandshakeCB will be uninstalled before handshakeSuc() is called.

Parameters
sockSSL socket on which the handshake was initiated

Implements folly::AsyncSSLSocket::HandshakeCB.

Definition at line 998 of file AsyncSSLSocketTest.h.

References folly::INFO, and folly::SendMsgParamsCallbackBase::socket_.

998  {
999  LOG(INFO) << "Renegotiating server handshake success";
1000  socket_->setReadCB(this);
1001  }
AsyncSSLSocket::UniquePtr socket_
void folly::RenegotiatingServer::readDataAvailable ( size_t  len)
inlineoverridevirtualnoexcept

readDataAvailable() will be invoked when data has been successfully read into the buffer returned by the last call to getReadBuffer().

The read callback remains installed after readDataAvailable() returns. It must be explicitly uninstalled to stop receiving read events. getReadBuffer() will be called at least once before each call to readDataAvailable(). getReadBuffer() will also be called before any call to readEOF().

Parameters
lenThe number of bytes placed in the buffer.

Implements folly::AsyncReader::ReadCallback.

Definition at line 1011 of file AsyncSSLSocketTest.h.

1011 {}
void folly::RenegotiatingServer::readEOF ( )
inlineoverridevirtualnoexcept

readEOF() will be invoked when the transport is closed.

The read callback will be automatically uninstalled immediately before readEOF() is invoked.

Implements folly::AsyncReader::ReadCallback.

Definition at line 1012 of file AsyncSSLSocketTest.h.

1012 {}
void folly::RenegotiatingServer::readErr ( const AsyncSocketException ex)
inlineoverridevirtualnoexcept

readError() will be invoked if an error occurs reading from the transport.

The read callback will be automatically uninstalled immediately before readError() is invoked.

Parameters
exAn exception describing the error that occurred.

Implements folly::AsyncReader::ReadCallback.

Definition at line 1013 of file AsyncSSLSocketTest.h.

References ASSERT_NE, folly::CLIENT_RENEGOTIATION, folly::INFO, and string.

1013  {
1014  LOG(INFO) << "server got read error " << ex.what();
1015  auto exPtr = dynamic_cast<const SSLException*>(&ex);
1016  ASSERT_NE(nullptr, exPtr);
1017  std::string exStr(ex.what());
1018  SSLException sslEx(SSLError::CLIENT_RENEGOTIATION);
1019  ASSERT_NE(std::string::npos, exStr.find(sslEx.what()));
1020  renegotiationError_ = true;
1021  }
const char * string
Definition: Conv.cpp:212
#define ASSERT_NE(val1, val2)
Definition: gtest.h:1960

Member Data Documentation

unsigned char folly::RenegotiatingServer::buf[128]

Definition at line 1024 of file AsyncSSLSocketTest.h.

bool folly::RenegotiatingServer::renegotiationError_ {false}

Definition at line 1025 of file AsyncSSLSocketTest.h.

Referenced by folly::TEST().

AsyncSSLSocket::UniquePtr folly::RenegotiatingServer::socket_

Definition at line 1023 of file AsyncSSLSocketTest.h.


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