X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2Fio%2Fasync%2FSSLContext.cpp;h=7ce05f44a7a062c974ffe8a65dd17c1bc1293f40;hp=45936d0ce3a78b1bf99e2e722d3e042781a19c75;hb=3e19d28a142149241d81c5e736aa4117fe7cbec8;hpb=b669462b65cacda010d6dca11bc56f9aee768ebc diff --git a/folly/io/async/SSLContext.cpp b/folly/io/async/SSLContext.cpp index 45936d0c..7ce05f44 100644 --- a/folly/io/async/SSLContext.cpp +++ b/folly/io/async/SSLContext.cpp @@ -21,8 +21,8 @@ #include #include #include -#include #include +#include // --------------------------------------------------------------------- // SSLContext implementation @@ -87,30 +87,6 @@ void SSLContext::ciphers(const std::string& ciphers) { setCiphersOrThrow(ciphers); } -void SSLContext::setCipherList(const std::vector& ciphers) { - if (ciphers.size() == 0) { - return; - } - std::string opensslCipherList; - join(":", ciphers, opensslCipherList); - setCiphersOrThrow(opensslCipherList); -} - -void SSLContext::setSignatureAlgorithms( - const std::vector& sigalgs) { - if (sigalgs.size() == 0) { - return; - } -#if OPENSSL_VERSION_NUMBER >= 0x1000200fL - std::string opensslSigAlgsList; - join(":", sigalgs, opensslSigAlgsList); - int rc = SSL_CTX_set1_sigalgs_list(ctx_, opensslSigAlgsList.c_str()); - if (rc == 0) { - throw std::runtime_error("SSL_CTX_set1_sigalgs_list " + getErrors()); - } -#endif -} - void SSLContext::setClientECCurvesList( const std::vector& ecCurves) { if (ecCurves.size() == 0) { @@ -311,6 +287,26 @@ void SSLContext::loadPrivateKeyFromBufferPEM(folly::StringPiece pkey) { } } +void SSLContext::loadCertKeyPairFromBufferPEM( + folly::StringPiece cert, + folly::StringPiece pkey) { + loadCertificateFromBufferPEM(cert); + loadPrivateKeyFromBufferPEM(pkey); +} + +void SSLContext::loadCertKeyPairFromFiles( + const char* certPath, + const char* keyPath, + const char* certFormat, + const char* keyFormat) { + loadCertificate(certPath, certFormat); + loadPrivateKey(keyPath, keyFormat); +} + +bool SSLContext::isCertKeyPairValid() const { + return SSL_CTX_check_private_key(ctx_) == 1; +} + void SSLContext::loadTrustedCertificates(const char* path) { if (path == nullptr) { throw std::invalid_argument("loadTrustedCertificates: is nullptr"); @@ -597,8 +593,7 @@ void SSLContext::setSessionCacheContext(const std::string& context) { ctx_, reinterpret_cast(context.data()), std::min( - static_cast(context.length()), - SSL_MAX_SSL_SESSION_ID_LENGTH)); + static_cast(context.length()), SSL_MAX_SID_CTX_LENGTH)); } /** @@ -650,10 +645,6 @@ int SSLContext::passwordCallback(char* password, return int(length); } -void SSLContext::setSSLLockTypes(std::map inLockTypes) { - folly::ssl::setLockTypes(inLockTypes); -} - #if defined(SSL_MODE_HANDSHAKE_CUTTHROUGH) void SSLContext::enableFalseStart() { SSL_CTX_set_mode(ctx_, SSL_MODE_HANDSHAKE_CUTTHROUGH);