proxygen
|
#include <OpenSSLUtils.h>
Static Public Member Functions | |
static bool | getTLSMasterKey (const SSL_SESSION *session, MutableByteRange keyOut) |
static bool | getTLSClientRandom (const SSL *ssl, MutableByteRange randomOut) |
static bool | validatePeerCertNames (X509 *cert, const sockaddr *addr, socklen_t addrLen) |
static bool | getPeerAddressFromX509StoreCtx (X509_STORE_CTX *ctx, sockaddr_storage *addrStorage, socklen_t *addrLen) |
static const std::string & | getCipherName (uint16_t cipherCode) |
static void | setSSLInitialCtx (SSL *ssl, SSL_CTX *ctx) |
static SSL_CTX * | getSSLInitialCtx (SSL *ssl) |
static std::string | getCommonName (X509 *x509) |
static BioMethodUniquePtr | newSocketBioMethod () |
static bool | setCustomBioReadMethod (BIO_METHOD *bioMeth, int(*meth)(BIO *, char *, int)) |
static bool | setCustomBioWriteMethod (BIO_METHOD *bioMeth, int(*meth)(BIO *, const char *, int)) |
static int | getBioShouldRetryWrite (int ret) |
static void | setBioAppData (BIO *b, void *ptr) |
static void * | getBioAppData (BIO *b) |
static int | getBioFd (BIO *b, int *fd) |
static void | setBioFd (BIO *b, int fd, int flags) |
Definition at line 26 of file OpenSSLUtils.h.
|
static |
Definition at line 284 of file OpenSSLUtils.cpp.
Referenced by folly::AsyncSSLSocket::bioRead(), and folly::AsyncSSLSocket::bioWrite().
|
static |
Definition at line 292 of file OpenSSLUtils.cpp.
Referenced by folly::AsyncSSLSocket::bioRead(), and folly::AsyncSSLSocket::bioWrite().
|
static |
Definition at line 266 of file OpenSSLUtils.cpp.
Referenced by folly::AsyncSSLSocket::bioRead(), and folly::AsyncSSLSocket::bioWrite().
|
static |
Get a stringified cipher name (e.g., ECDHE-ECDSA-CHACHA20-POLY1305) given the 2-byte code (e.g., 0xcca9) for the cipher. The name conversion only works for the ciphers built into the linked OpenSSL library
cipherCode | A 16-bit IANA cipher code (machine endianness) |
Definition at line 188 of file OpenSSLUtils.cpp.
References folly::empty(), folly::ssl::getOpenSSLCipherNames(), and string.
Referenced by folly::AsyncSSLSocket::getSSLClientCiphers().
|
static |
Get the common name out of a cert. Return empty if x509 is null.
Definition at line 317 of file OpenSSLUtils.cpp.
|
static |
Get the peer socket address from an X509_STORE_CTX*. Unlike the accept, getsockname, getpeername, etc family of operations, addrLen's initial value is ignored and reset.
ctx | Context from which to retrieve peer sockaddr |
addrStorage | out param for address |
addrLen | out param for length of address |
Definition at line 75 of file OpenSSLUtils.cpp.
References folly::netops::getpeername().
|
static |
Definition at line 215 of file OpenSSLUtils.cpp.
Referenced by folly::AsyncSSLSocket::sslAccept().
|
static |
Definition at line 58 of file OpenSSLUtils.cpp.
References folly::Range< Iter >::begin(), folly::copy(), and folly::Range< Iter >::size().
|
static |
Definition at line 40 of file OpenSSLUtils.cpp.
References folly::Range< Iter >::begin(), folly::copy(), and folly::Range< Iter >::size().
|
static |
Wrappers for BIO operations that may be different across different versions/flavors of OpenSSL (including forks like BoringSSL)
Definition at line 225 of file OpenSSLUtils.cpp.
References folly::portability::ssl::BIO_meth_new(), folly::portability::ssl::BIO_meth_set_create(), folly::portability::ssl::BIO_meth_set_ctrl(), folly::portability::ssl::BIO_meth_set_destroy(), folly::portability::ssl::BIO_meth_set_gets(), folly::portability::ssl::BIO_meth_set_puts(), folly::portability::ssl::BIO_meth_set_read(), and folly::portability::ssl::BIO_meth_set_write().
|
static |
Definition at line 276 of file OpenSSLUtils.cpp.
Referenced by folly::AsyncSSLSocket::setupSSLBio().
|
static |
Definition at line 304 of file OpenSSLUtils.cpp.
References folly::netops::socket().
Referenced by folly::AsyncSSLSocket::setupSSLBio().
|
static |
Definition at line 250 of file OpenSSLUtils.cpp.
References folly::portability::ssl::BIO_meth_set_read().
|
static |
Definition at line 258 of file OpenSSLUtils.cpp.
References folly::portability::ssl::BIO_meth_set_write().
|
static |
Set the 'initial_ctx' SSL_CTX* inside an SSL. The initial_ctx is used to point to the SSL_CTX on which servername callback and session callbacks, as well as session caching stats are set. If we want to enforce SSL_CTX thread-based ownership (e.g., thread-local SSL_CTX) in the application, we need to also set/reset the initial_ctx when we call SSL_set_SSL_CTX.
ssl | SSL pointer |
ctx | SSL_CTX pointer |
Definition at line 202 of file OpenSSLUtils.cpp.
Referenced by folly::AsyncSSLSocket::sslAccept().
|
static |
Validate that the peer certificate's common name or subject alt names match what we expect. Currently this only checks for IPs within subject alt names but it could easily be expanded to check common name and hostnames as well.
cert | X509* peer certificate |
addr | sockaddr object containing sockaddr to verify |
addrLen | length of sockaddr as returned by getpeername or accept |
Definition at line 98 of file OpenSSLUtils.cpp.
References addr, folly::FATAL, i, name, SCOPE_EXIT, folly::portability::ssl::STACK_OF(), and folly::WARNING.