proxygen
AsyncSSLSocket.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <iomanip>
20 
21 #include <folly/Optional.h>
22 #include <folly/String.h>
23 #include <folly/io/Cursor.h>
24 #include <folly/io/IOBuf.h>
33 #include <folly/lang/Bits.h>
37 
38 namespace folly {
39 
70 class AsyncSSLSocket : public virtual AsyncSocket {
71  public:
72  typedef std::unique_ptr<AsyncSSLSocket, Destructor> UniquePtr;
74 
75  class HandshakeCB {
76  public:
77  virtual ~HandshakeCB() = default;
78 
93  virtual bool handshakeVer(
94  AsyncSSLSocket* /*sock*/,
95  bool preverifyOk,
96  X509_STORE_CTX* /*ctx*/) noexcept {
97  return preverifyOk;
98  }
99 
109  virtual void handshakeSuc(AsyncSSLSocket* sock) noexcept = 0;
110 
121  virtual void handshakeErr(
122  AsyncSSLSocket* sock,
123  const AsyncSocketException& ex) noexcept = 0;
124  };
125 
126  class Timeout : public AsyncTimeout {
127  public:
128  Timeout(AsyncSSLSocket* sslSocket, EventBase* eventBase)
129  : AsyncTimeout(eventBase), sslSocket_(sslSocket) {}
130 
132  timeout_ = timeout;
133  return AsyncTimeout::scheduleTimeout(timeout);
134  }
135 
136  bool scheduleTimeout(uint32_t timeoutMs) {
137  return scheduleTimeout(std::chrono::milliseconds{timeoutMs});
138  }
139 
141  return timeout_;
142  }
143 
144  void timeoutExpired() noexcept override {
145  sslSocket_->timeoutExpired(timeout_);
146  }
147 
148  private:
151  };
152 
157  public:
160  AsyncSSLSocket* sslSocket,
161  DestructorGuard dg)
162  : pipeReader_(std::move(reader)),
163  sslSocket_(sslSocket),
164  dg_(std::move(dg)) {}
165 
167  pipeReader_->setReadCB(nullptr);
168  sslSocket_->setAsyncOperationFinishCallback(nullptr);
169  }
170 
171  void readDataAvailable(size_t len) noexcept override {
172  CHECK_EQ(len, 1);
173  sslSocket_->restartSSLAccept();
174  pipeReader_->setReadCB(nullptr);
175  sslSocket_->setAsyncOperationFinishCallback(nullptr);
176  }
177 
178  void getReadBuffer(void** bufReturn, size_t* lenReturn) noexcept override {
179  *bufReturn = &byte_;
180  *lenReturn = 1;
181  }
182 
183  void readEOF() noexcept override {}
184 
186 
187  private:
188  uint8_t byte_{0};
192  };
193 
198  const std::shared_ptr<folly::SSLContext>& ctx,
199  EventBase* evb,
200  bool deferSecurityNegotiation = false);
201 
220  const std::shared_ptr<folly::SSLContext>& ctx,
221  EventBase* evb,
222  int fd,
223  bool server = true,
224  bool deferSecurityNegotiation = false);
225 
231  const std::shared_ptr<folly::SSLContext>& ctx,
232  AsyncSocket::UniquePtr oldAsyncSocket,
233  bool server = true,
234  bool deferSecurityNegotiation = false);
235 
239  static std::shared_ptr<AsyncSSLSocket> newSocket(
240  const std::shared_ptr<folly::SSLContext>& ctx,
241  EventBase* evb,
242  int fd,
243  bool server = true,
244  bool deferSecurityNegotiation = false) {
245  return std::shared_ptr<AsyncSSLSocket>(
246  new AsyncSSLSocket(ctx, evb, fd, server, deferSecurityNegotiation),
247  Destructor());
248  }
249 
253  static std::shared_ptr<AsyncSSLSocket> newSocket(
254  const std::shared_ptr<folly::SSLContext>& ctx,
255  EventBase* evb,
256  bool deferSecurityNegotiation = false) {
257  return std::shared_ptr<AsyncSSLSocket>(
258  new AsyncSSLSocket(ctx, evb, deferSecurityNegotiation), Destructor());
259  }
260 
261 #if FOLLY_OPENSSL_HAS_SNI
262 
267  const std::shared_ptr<folly::SSLContext>& ctx,
268  EventBase* evb,
269  const std::string& serverName,
270  bool deferSecurityNegotiation = false);
271 
288  const std::shared_ptr<folly::SSLContext>& ctx,
289  EventBase* evb,
290  int fd,
291  const std::string& serverName,
292  bool deferSecurityNegotiation = false);
293 
294  static std::shared_ptr<AsyncSSLSocket> newSocket(
295  const std::shared_ptr<folly::SSLContext>& ctx,
296  EventBase* evb,
297  const std::string& serverName,
298  bool deferSecurityNegotiation = false) {
299  return std::shared_ptr<AsyncSSLSocket>(
300  new AsyncSSLSocket(ctx, evb, serverName, deferSecurityNegotiation),
301  Destructor());
302  }
303 #endif // FOLLY_OPENSSL_HAS_SNI
304 
318  // Inherit TAsyncTransport methods from AsyncSocket except the
319  // following.
320  // See the documentation in TAsyncTransport.h
321  // TODO: implement graceful shutdown in close()
322  // TODO: implement detachSSL() that returns the SSL connection
323  void closeNow() override;
324  void shutdownWrite() override;
325  void shutdownWriteNow() override;
326  bool good() const override;
327  bool connecting() const override;
329 
330  std::string getSecurityProtocol() const override {
331  if (sslState_ == STATE_UNENCRYPTED) {
332  return "";
333  }
334  return "TLS";
335  }
336 
337  void setEorTracking(bool track) override;
338  size_t getRawBytesWritten() const override;
339  size_t getRawBytesReceived() const override;
341 
357  virtual void sslAccept(
358  HandshakeCB* callback,
359  std::chrono::milliseconds timeout = std::chrono::milliseconds::zero(),
360  const folly::SSLContext::SSLVerifyPeerEnum& verifyPeer =
361  folly::SSLContext::SSLVerifyPeerEnum::USE_CTX);
362 
366  void restartSSLAccept();
367 
373  void connect(
374  ConnectCallback* callback,
375  const folly::SocketAddress& address,
376  int timeout = 0,
377  const OptionMap& options = emptyOptionMap,
378  const folly::SocketAddress& bindAddr = anyAddress()) noexcept override;
379 
395  virtual void connect(
396  ConnectCallback* callback,
397  const folly::SocketAddress& address,
398  std::chrono::milliseconds connectTimeout,
399  std::chrono::milliseconds totalConnectTimeout,
400  const OptionMap& options = emptyOptionMap,
401  const folly::SocketAddress& bindAddr = anyAddress()) noexcept;
402 
403  using AsyncSocket::connect;
404 
422  virtual void sslConn(
423  HandshakeCB* callback,
424  std::chrono::milliseconds timeout = std::chrono::milliseconds::zero(),
425  const folly::SSLContext::SSLVerifyPeerEnum& verifyPeer =
426  folly::SSLContext::SSLVerifyPeerEnum::USE_CTX);
427 
442  };
443 
445  return sslState_;
446  }
447 
452  SSL_SESSION* getSSLSession();
453 
457  const SSL* getSSL() const;
458 
467  void setSSLSession(SSL_SESSION* session, bool takeOwnership = false);
468 
483  virtual void getSelectedNextProtocol(
484  const unsigned char** protoName,
485  unsigned* protoLen) const;
486 
501  virtual bool getSelectedNextProtocolNoThrow(
502  const unsigned char** protoName,
503  unsigned* protoLen) const;
504 
509  virtual bool getSSLSessionReused() const;
510 
514  bool sessionIDResumed() const {
515  return sessionIDResumed_;
516  }
517 
518  void setSessionIDResumed(bool resumed) {
519  sessionIDResumed_ = resumed;
520  }
521 
527  virtual const char* getNegotiatedCipherName() const;
528 
535  const char* getSSLServerName() const;
536 
543  const char* getSSLServerNameNoThrow() const;
544 
551  int getSSLVersion() const;
552 
557  const char* getSSLCertSigAlgName() const;
558 
562  int getSSLCertSize() const;
563 
567  const X509* getSelfCert() const override;
568 
569  void attachEventBase(EventBase* eventBase) override {
570  AsyncSocket::attachEventBase(eventBase);
573  }
574 
575  void detachEventBase() override {
579  }
580 
581  bool isDetachable() const override {
583  }
584 
585  virtual void attachTimeoutManager(TimeoutManager* manager) {
587  }
588 
589  virtual void detachTimeoutManager() {
591  }
592 
593 #if OPENSSL_VERSION_NUMBER >= 0x009080bfL
594 
599  void attachSSLContext(const std::shared_ptr<folly::SSLContext>& ctx);
600 
604  void detachSSLContext();
605 #endif
606 
615  const std::shared_ptr<folly::SSLContext>& getSSLContext() const {
616  return ctx_;
617  }
618 
619 #if FOLLY_OPENSSL_HAS_SNI
620 
624  void switchServerSSLContext(
625  const std::shared_ptr<folly::SSLContext>& handshakeCtx);
626 
635  bool isServerNameMatch() const;
636 
641  void setServerName(std::string serverName) noexcept;
642 #endif // FOLLY_OPENSSL_HAS_SNI
643 
644  void timeoutExpired(std::chrono::milliseconds timeout) noexcept;
645 
650  void getSSLClientCiphers(
651  std::string& clientCiphers,
652  bool convertToString = true) const;
653 
658 
663 
665 
671 
673 
674  /*
675  * Save an optional alert message generated during certificate verify
676  */
678 
680 
685  void getSSLSharedCiphers(std::string& sharedCiphers) const;
686 
691  void getSSLServerCiphers(std::string& serverCiphers) const;
692 
698  bool needsPeerVerification() const;
699 
700  static int getSSLExDataIndex();
701  static AsyncSSLSocket* getFromSSL(const SSL* ssl);
702  static int bioWrite(BIO* b, const char* in, int inl);
703  static int bioRead(BIO* b, char* out, int outl);
704  void resetClientHelloParsing(SSL* ssl);
705  static void clientHelloParsingCallback(
706  int write_p,
707  int version,
708  int content_type,
709  const void* buf,
710  size_t len,
711  SSL* ssl,
712  void* arg);
713  static const char* getSSLServerNameFromSSL(SSL* ssl);
714 
715  // For unit-tests
717  return clientHelloInfo_.get();
718  }
719 
723  virtual std::chrono::nanoseconds getHandshakeTime() const {
725  }
726 
727  void setMinWriteSize(size_t minWriteSize) {
728  minWriteSize_ = minWriteSize;
729  }
730 
731  size_t getMinWriteSize() const {
732  return minWriteSize_;
733  }
734 
735  void setReadCB(ReadCallback* callback) override;
736 
742  void setBufferMovableEnabled(bool enabled);
743 
744  const AsyncTransportCertificate* getPeerCertificate() const override;
745  const AsyncTransportCertificate* getSelfCertificate() const override;
746 
750  ssl::X509UniquePtr getPeerCert() const override {
751  auto peerCert = getPeerCertificate();
752  if (!peerCert) {
753  return nullptr;
754  }
755  return peerCert->getX509();
756  }
757 
765  void forceCacheAddrOnFailure(bool force) {
766  cacheAddrOnFailure_ = force;
767  }
768 
769  const std::string& getSessionKey() const {
770  return sessionKey_;
771  }
772 
773  void setSessionKey(std::string sessionKey) {
774  sessionKey_ = std::move(sessionKey);
775  }
776 
777  void setCertCacheHit(bool hit) {
778  certCacheHit_ = hit;
779  }
780 
781  bool getCertCacheHit() const {
782  return certCacheHit_;
783  }
784 
787  }
788 
795  std::chrono::milliseconds getTotalConnectTimeout() const {
796  return totalConnectTimeout_;
797  }
798 
799  // This can be called for OpenSSL 1.1.0 async operation finishes
800  void setAsyncOperationFinishCallback(std::unique_ptr<ReadCallback> cb) {
802  }
803 
804  private:
808  void handleReturnFromSSLAccept(int ret);
809 
810  void init();
811 
812  protected:
820  ~AsyncSSLSocket() override;
821 
822  // Inherit event notification methods from AsyncSocket except
823  // the following.
824  void prepareReadBuffer(void** buf, size_t* buflen) override;
825  void handleRead() noexcept override;
826  void handleWrite() noexcept override;
827  void handleAccept() noexcept;
828  void handleConnect() noexcept override;
829 
830  void invalidState(HandshakeCB* callback);
831  bool
832  willBlock(int ret, int* sslErrorOut, unsigned long* errErrorOut) noexcept;
833 
834  void checkForImmediateRead() noexcept override;
835  // AsyncSocket calls this at the wrong time for SSL
836  void handleInitialReadWrite() noexcept override {}
837 
838  WriteResult interpretSSLError(int rc, int error);
839  ReadResult performRead(void** buf, size_t* buflen, size_t* offset) override;
841  const iovec* vec,
842  uint32_t count,
844  uint32_t* countWritten,
845  uint32_t* partialWritten) override;
846 
847  ssize_t performWriteIovec(
848  const iovec* vec,
849  uint32_t count,
850  WriteFlags flags,
851  uint32_t* countWritten,
852  uint32_t* partialWritten);
853 
854  // This virtual wrapper around SSL_write exists solely for testing/mockability
855  virtual int sslWriteImpl(SSL* ssl, const void* buf, int n) {
856  return SSL_write(ssl, buf, n);
857  }
858 
868 
874  bool setupSSLBio();
875 
885  int eorAwareSSLWrite(
886  const ssl::SSLUniquePtr& ssl,
887  const void* buf,
888  int n,
889  bool eor);
890 
891  // Inherit error handling methods from AsyncSocket, plus the following.
892  void failHandshake(const char* fn, const AsyncSocketException& ex);
893 
895  void invokeHandshakeCB();
896 
897  void invokeConnectErr(const AsyncSocketException& ex) override;
898  void invokeConnectSuccess() override;
899  void scheduleConnectTimeout() override;
900 
901  void startSSLConnect();
902 
903  static void sslInfoCallback(const SSL* ssl, int type, int val);
904 
905  // Whether the current write to the socket should use MSG_MORE.
906  bool corkCurrentWrite_{false};
907  // SSL related members.
908  bool server_{false};
909  // Used to prevent client-initiated renegotiation. Note that AsyncSSLSocket
910  // doesn't fully support renegotiation, so we could just fail all attempts
911  // to enforce this. Once it is supported, we should make it an option
912  // to disable client-initiated renegotiation.
913  bool handshakeComplete_{false};
916  std::shared_ptr<folly::SSLContext> ctx_;
917  // Callback for SSL_accept() or SSL_connect()
920  SSL_SESSION* sslSession_{nullptr};
923 
924  // The app byte num that we are tracking for the MSG_EOR
925  // Only one app EOR byte can be tracked.
926  size_t appEorByteNo_{0};
927 
928  // Try to avoid calling SSL_write() for buffers smaller than this.
929  // It doesn't take effect when it is 0.
930  size_t minWriteSize_{1500};
931 
932  // When openssl is about to sendmsg() across the minEorRawBytesNo_,
933  // it will pass MSG_EOR to sendmsg().
934  size_t minEorRawByteNo_{0};
935 #if FOLLY_OPENSSL_HAS_SNI
936  std::shared_ptr<folly::SSLContext> handshakeCtx_;
937  std::string tlsextHostname_;
938 #endif
939 
940  // a key that can be used for caching the established session
942 
944  folly::SSLContext::SSLVerifyPeerEnum::USE_CTX};
945 
946  // Callback for SSL_CTX_set_verify()
947  static int sslVerifyCallback(int preverifyOk, X509_STORE_CTX* ctx);
948 
949  bool parseClientHello_{false};
950  bool cacheAddrOnFailure_{false};
952  bool certCacheHit_{false};
953  std::unique_ptr<ssl::ClientHelloInfo> clientHelloInfo_;
954  std::vector<std::pair<char, StringPiece>> alertsReceived_;
955 
956  // Time taken to complete the ssl handshake.
957  std::chrono::steady_clock::time_point handshakeStartTime_;
958  std::chrono::steady_clock::time_point handshakeEndTime_;
959  std::chrono::milliseconds handshakeConnectTimeout_{0};
960  std::chrono::milliseconds totalConnectTimeout_{0};
961 
963 
965  // whether the SSL session was resumed using session ID or not
966  bool sessionIDResumed_{false};
967  // This can be called for OpenSSL 1.1.0 async operation finishes
968  std::unique_ptr<ReadCallback> asyncOperationFinishCallback_;
969 };
970 
971 } // namespace folly
void detachEventBase() override
void applyVerificationOptions(const ssl::SSLUniquePtr &ssl)
bool good() const override
size_t getRawBytesReceived() const override
void checkForImmediateRead() noexceptoverride
ReadResult performRead(void **buf, size_t *buflen, size_t *offset) override
void invokeHandshakeErr(const AsyncSocketException &ex)
flags
Definition: http_parser.h:127
bool sessionIDResumed() const
DefaultOpenSSLAsyncFinishCallback(AsyncPipeReader::UniquePtr reader, AsyncSSLSocket *sslSocket, DestructorGuard dg)
std::unique_ptr< AsyncPipeReader, folly::DelayedDestruction::Destructor > UniquePtr
Definition: AsyncPipe.h:40
bool sessionResumptionAttempted() const
std::chrono::milliseconds timeout_type
std::unique_ptr< ReadCallback > asyncOperationFinishCallback_
std::unique_ptr< X509, X509Deleter > X509UniquePtr
void handleInitialReadWrite() noexceptoverride
void handleRead() noexceptoverride
char b
WriteResult interpretSSLError(int rc, int error)
bool connecting() const override
static int sslVerifyCallback(int preverifyOk, X509_STORE_CTX *ctx)
static int bioRead(BIO *b, char *out, int outl)
static const char * getSSLServerNameFromSSL(SSL *ssl)
close() called with pending writes, before connect() has completed
folly::SSLContext::SSLVerifyPeerEnum verifyPeer_
PskType type
virtual void attachTimeoutManager(TimeoutManager *manager)
void setEorTracking(bool track) override
void connect(ConnectCallback *callback, const folly::SocketAddress &address, int timeout=0, const OptionMap &options=emptyOptionMap, const folly::SocketAddress &bindAddr=anyAddress()) noexceptoverride
void timeoutExpired() noexceptoverride
const char * getSSLCertSigAlgName() const
size_t getRawBytesWritten() const override
bool willBlock(int ret, int *sslErrorOut, unsigned long *errErrorOut) noexcept
std::string getSSLClientComprMethods() const
std::string getSSLClientSupportedVersions() const
const AsyncTransportCertificate * getPeerCertificate() const override
const X509 * getSelfCert() const override
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
ssl::SSLUniquePtr ssl_
virtual void sslAccept(HandshakeCB *callback, std::chrono::milliseconds timeout=std::chrono::milliseconds::zero(), const folly::SSLContext::SSLVerifyPeerEnum &verifyPeer=folly::SSLContext::SSLVerifyPeerEnum::USE_CTX)
WriteResult performWrite(const iovec *vec, uint32_t count, WriteFlags flags, uint32_t *countWritten, uint32_t *partialWritten) override
std::string getSecurityProtocol() const override
STL namespace.
virtual void sslConn(HandshakeCB *callback, std::chrono::milliseconds timeout=std::chrono::milliseconds::zero(), const folly::SSLContext::SSLVerifyPeerEnum &verifyPeer=folly::SSLContext::SSLVerifyPeerEnum::USE_CTX)
double val
Definition: String.cpp:273
std::chrono::milliseconds handshakeConnectTimeout_
SSL_SESSION * sslSession_
void setSessionIDResumed(bool resumed)
const char * getSSLServerName() const
void shutdownWrite() override
void setAsyncOperationFinishCallback(std::unique_ptr< ReadCallback > cb)
std::string sslVerificationAlert_
Timeout(AsyncSSLSocket *sslSocket, EventBase *eventBase)
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
requires E e noexcept(noexcept(s.error(std::move(e))))
bool error() const override
const std::shared_ptr< folly::SSLContext > & getSSLContext() const
virtual void detachTimeoutManager()
void setMinWriteSize(size_t minWriteSize)
static std::shared_ptr< AsyncSSLSocket > newSocket(const std::shared_ptr< folly::SSLContext > &ctx, EventBase *evb, int fd, bool server=true, bool deferSecurityNegotiation=false)
virtual void connect(ConnectCallback *callback, const folly::SocketAddress &address, int timeout=0, const OptionMap &options=emptyOptionMap, const folly::SocketAddress &bindAddr=anyAddress()) noexcept
bool needsPeerVerification() const
void attachEventBase(EventBase *eventBase) override
ssize_t performWriteIovec(const iovec *vec, uint32_t count, WriteFlags flags, uint32_t *countWritten, uint32_t *partialWritten)
std::shared_ptr< folly::SSLContext > ctx_
void scheduleConnectTimeout() override
ProtocolVersion version
void setReadCB(ReadCallback *callback) override
void handleWrite() noexceptoverride
std::unique_ptr< AsyncSSLSocket, Destructor > UniquePtr
ssl::X509UniquePtr getPeerCert() const override
void setCertCacheHit(bool hit)
std::chrono::milliseconds totalConnectTimeout_
std::map< OptionKey, int > OptionMap
Definition: AsyncSocket.h:376
SSLStateEnum getSSLState() const
void setSessionKey(std::string sessionKey)
void invokeConnectSuccess() override
static const folly::SocketAddress & anyAddress()
void attachTimeoutManager(TimeoutManager *timeoutManager, InternalEnum internal=InternalEnum::NORMAL)
AsyncSSLSocket::UniquePtr sslSocket_
void detachEventBase() override
void handleReturnFromSSLAccept(int ret)
void readErr(const folly::AsyncSocketException &) noexceptoverride
ssl::ClientHelloInfo * getClientHelloInfo() const
std::string getSSLCertVerificationAlert() const
static void clientHelloParsingCallback(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)
void invokeConnectErr(const AsyncSocketException &ex) override
void timeoutExpired() noexcept
void forceCacheAddrOnFailure(bool force)
static const OptionMap emptyOptionMap
Definition: AsyncSocket.h:378
TimeoutManager::timeout_type getTimeout()
Definition: Traits.h:588
void getSSLClientCiphers(std::string &clientCiphers, bool convertToString=true) const
void setBufferMovableEnabled(bool enabled)
remote end closed; we can still write
bool getCertCacheHit() const
virtual bool getSSLSessionReused() const
void getSSLSharedCiphers(std::string &sharedCiphers) const
bool isDetachable() const override
const std::string & getSessionKey() const
void attachEventBase(EventBase *eventBase) override
void attachEventBase(EventBase *eventBase, InternalEnum internal=InternalEnum::NORMAL)
virtual void handshakeSuc(AsyncSSLSocket *sock) noexcept=0
void prepareReadBuffer(void **buf, size_t *buflen) override
int * count
void getReadBuffer(void **bufReturn, size_t *lenReturn) noexceptoverride
void handleConnect() noexceptoverride
virtual bool handshakeVer(AsyncSSLSocket *, bool preverifyOk, X509_STORE_CTX *) noexcept
virtual void handshakeErr(AsyncSSLSocket *sock, const AsyncSocketException &ex) noexcept=0
void setSSLCertVerificationAlert(std::string alert)
virtual bool getSelectedNextProtocolNoThrow(const unsigned char **protoName, unsigned *protoLen) const
std::vector< std::pair< char, StringPiece > > alertsReceived_
std::unique_ptr< ssl::ClientHelloInfo > clientHelloInfo_
std::string getSSLClientExts() const
void getSSLServerCiphers(std::string &serverCiphers) const
TimeoutManager::timeout_type timeout_
AsyncSSLSocket(const std::shared_ptr< folly::SSLContext > &ctx, EventBase *evb, bool deferSecurityNegotiation=false)
std::chrono::steady_clock::time_point handshakeEndTime_
std::string getSSLClientSigAlgs() const
const char * string
Definition: Conv.cpp:212
SSL_SESSION * getSSLSession()
void resetClientHelloParsing(SSL *ssl)
virtual std::chrono::nanoseconds getHandshakeTime() const
bool scheduleTimeout(uint32_t milliseconds)
void setSSLSession(SSL_SESSION *session, bool takeOwnership=false)
HandshakeCB * handshakeCallback_
std::string getSSLAlertsReceived() const
bool isScheduled() const
void failHandshake(const char *fn, const AsyncSocketException &ex)
int eorAwareSSLWrite(const ssl::SSLUniquePtr &ssl, const void *buf, int n, bool eor)
void invalidState(HandshakeCB *callback)
std::chrono::steady_clock::time_point handshakeStartTime_
bool scheduleTimeout(TimeoutManager::timeout_type timeout)
bool scheduleTimeout(uint32_t timeoutMs)
std::string getApplicationProtocol() const noexceptoverride
bool isDetachable() const override
const SSL * getSSL() const
const AsyncTransportCertificate * getSelfCertificate() const override
static int bioWrite(BIO *b, const char *in, int inl)
std::chrono::milliseconds getTotalConnectTimeout() const
static std::shared_ptr< AsyncSSLSocket > newSocket(const std::shared_ptr< folly::SSLContext > &ctx, EventBase *evb, bool deferSecurityNegotiation=false)
virtual const char * getNegotiatedCipherName() const
void shutdownWriteNow() override
size_t getMinWriteSize() const
static void sslInfoCallback(const SSL *ssl, int type, int val)
static AsyncSSLSocket * getFromSSL(const SSL *ssl)
std::unique_ptr< AsyncSocket, Destructor > UniquePtr
Definition: AsyncSocket.h:83
static int getSSLExDataIndex()
const char * getSSLServerNameNoThrow() const
virtual int sslWriteImpl(SSL *ssl, const void *buf, int n)
void closeNow() override
virtual void getSelectedNextProtocol(const unsigned char **protoName, unsigned *protoLen) const
void handleAccept() noexcept
std::unique_ptr< SSL, SSLDeleter > SSLUniquePtr