proxygen
folly::SSLHandshakeBase Class Reference

#include <AsyncSSLSocketTest.h>

Inheritance diagram for folly::SSLHandshakeBase:
folly::AsyncSSLSocket::HandshakeCB folly::AsyncWriter::WriteCallback folly::SSLHandshakeClient folly::SSLHandshakeClientDoVerify folly::SSLHandshakeClientNoVerify folly::SSLHandshakeServer folly::SSLHandshakeServerDoVerify folly::SSLHandshakeServerNoVerify folly::SSLHandshakeServerParseClientHello

Public Member Functions

 SSLHandshakeBase (AsyncSSLSocket::UniquePtr socket, bool preverifyResult, bool verifyResult)
 
AsyncSSLSocket::UniquePtr moveSocket ()&&
 
- Public Member Functions inherited from folly::AsyncSSLSocket::HandshakeCB
virtual ~HandshakeCB ()=default
 

Public Attributes

bool handshakeVerify_
 
bool handshakeSuccess_
 
bool handshakeError_
 
std::chrono::nanoseconds handshakeTime
 

Protected Member Functions

bool handshakeVer (AsyncSSLSocket *, bool preverifyOk, X509_STORE_CTX *) noexceptoverride
 
void handshakeSuc (AsyncSSLSocket *) noexceptoverride
 
void handshakeErr (AsyncSSLSocket *, const AsyncSocketException &ex) noexceptoverride
 
void writeSuccess () noexceptoverride
 
void writeErr (size_t bytesWritten, const AsyncSocketException &ex) noexceptoverride
 

Protected Attributes

AsyncSSLSocket::UniquePtr socket_
 
bool preverifyResult_
 
bool verifyResult_
 

Additional Inherited Members

- Private Member Functions inherited from folly::AsyncWriter::WriteCallback
virtual ~WriteCallback ()=default
 

Detailed Description

Definition at line 1270 of file AsyncSSLSocketTest.h.

Constructor & Destructor Documentation

folly::SSLHandshakeBase::SSLHandshakeBase ( AsyncSSLSocket::UniquePtr  socket,
bool  preverifyResult,
bool  verifyResult 
)
inlineexplicit

Definition at line 1273 of file AsyncSSLSocketTest.h.

1277  : handshakeVerify_(false),
1278  handshakeSuccess_(false),
1279  handshakeError_(false),
1281  preverifyResult_(preverifyResult),
1282  verifyResult_(verifyResult) {}
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
AsyncSSLSocket::UniquePtr socket_
NetworkSocket socket(int af, int type, int protocol)
Definition: NetOps.cpp:412

Member Function Documentation

void folly::SSLHandshakeBase::handshakeErr ( AsyncSSLSocket sock,
const AsyncSocketException ex 
)
inlineoverrideprotectedvirtualnoexcept

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 1317 of file AsyncSSLSocketTest.h.

References folly::INFO.

1319  {
1320  LOG(INFO) << "Handshake error " << ex.what();
1321  handshakeError_ = true;
1322  if (socket_) {
1323  handshakeTime = socket_->getHandshakeTime();
1324  }
1325  }
AsyncSSLSocket::UniquePtr socket_
std::chrono::nanoseconds handshakeTime
void folly::SSLHandshakeBase::handshakeSuc ( AsyncSSLSocket sock)
inlineoverrideprotectedvirtualnoexcept

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.

Reimplemented in folly::SSLHandshakeServerParseClientHello.

Definition at line 1309 of file AsyncSSLSocketTest.h.

References folly::INFO.

1309  {
1310  LOG(INFO) << "Handshake success";
1311  handshakeSuccess_ = true;
1312  if (socket_) {
1313  handshakeTime = socket_->getHandshakeTime();
1314  }
1315  }
AsyncSSLSocket::UniquePtr socket_
std::chrono::nanoseconds handshakeTime
bool folly::SSLHandshakeBase::handshakeVer ( AsyncSSLSocket ,
bool  preverifyOk,
X509_STORE_CTX *   
)
inlineoverrideprotectedvirtualnoexcept

handshakeVer() is invoked during handshaking to give the application chance to validate it's peer's certificate.

Note that OpenSSL performs only rudimentary internal consistency verification checks by itself. Any other validation like whether or not the certificate was issued by a trusted CA. The default implementation of this callback mimics what what OpenSSL does internally if SSL_VERIFY_PEER is set with no verification callback.

See the passages on verify_callback in SSL_CTX_set_verify(3) for more details.

Reimplemented from folly::AsyncSSLSocket::HandshakeCB.

Definition at line 1299 of file AsyncSSLSocketTest.h.

References EXPECT_EQ.

1302  {
1303  handshakeVerify_ = true;
1304 
1305  EXPECT_EQ(preverifyResult_, preverifyOk);
1306  return verifyResult_;
1307  }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
AsyncSSLSocket::UniquePtr folly::SSLHandshakeBase::moveSocket ( )
inline

Definition at line 1284 of file AsyncSSLSocketTest.h.

References folly::gen::move, and folly::SendMsgParamsCallbackBase::socket_.

1284  {
1285  return std::move(socket_);
1286  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
AsyncSSLSocket::UniquePtr socket_
void folly::SSLHandshakeBase::writeErr ( size_t  bytesWritten,
const AsyncSocketException ex 
)
inlineoverrideprotectedvirtualnoexcept

writeError() will be invoked if an error occurs writing the data.

Parameters
bytesWrittenThe number of bytes that were successfull
exAn exception describing the error that occurred.

Implements folly::AsyncWriter::WriteCallback.

Definition at line 1334 of file AsyncSSLSocketTest.h.

References ADD_FAILURE.

1336  {
1337  ADD_FAILURE() << "client write error after " << bytesWritten
1338  << " bytes: " << ex.what();
1339  }
#define ADD_FAILURE()
Definition: gtest.h:1808
void folly::SSLHandshakeBase::writeSuccess ( )
inlineoverrideprotectedvirtualnoexcept

writeSuccess() will be invoked when all of the data has been successfully written.

Note that this mainly signals that the buffer containing the data to write is no longer needed and may be freed or re-used. It does not guarantee that the data has been fully transmitted to the remote endpoint. For example, on socket-based transports, writeSuccess() only indicates that the data has been given to the kernel for eventual transmission.

Implements folly::AsyncWriter::WriteCallback.

Definition at line 1328 of file AsyncSSLSocketTest.h.

1328  {
1329  if (socket_) {
1330  socket_->close();
1331  }
1332  }
AsyncSSLSocket::UniquePtr socket_

Member Data Documentation

bool folly::SSLHandshakeBase::handshakeError_

Definition at line 1290 of file AsyncSSLSocketTest.h.

Referenced by folly::TEST().

bool folly::SSLHandshakeBase::handshakeSuccess_

Definition at line 1289 of file AsyncSSLSocketTest.h.

Referenced by folly::TEST(), and folly::TEST_F().

std::chrono::nanoseconds folly::SSLHandshakeBase::handshakeTime

Definition at line 1291 of file AsyncSSLSocketTest.h.

Referenced by folly::TEST().

bool folly::SSLHandshakeBase::handshakeVerify_

Definition at line 1288 of file AsyncSSLSocketTest.h.

Referenced by folly::TEST().

bool folly::SSLHandshakeBase::preverifyResult_
protected

Definition at line 1295 of file AsyncSSLSocketTest.h.

AsyncSSLSocket::UniquePtr folly::SSLHandshakeBase::socket_
protected

Definition at line 1294 of file AsyncSSLSocketTest.h.

bool folly::SSLHandshakeBase::verifyResult_
protected

Definition at line 1296 of file AsyncSSLSocketTest.h.


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