MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / connCreateAcceptedTLS

Function connCreateAcceptedTLS

src/tls.cpp:710–737  ·  view source on GitHub ↗

Create a new TLS connection that is already associated with * an accepted underlying file descriptor. * * The socket is not ready for I/O until connAccept() was called and * invoked the connection-level accept handler. * * Callers should use connGetState() and verify the created connection * is not in an error state. */

Source from the content-addressed store, hash-verified

708 * is not in an error state.
709 */
710connection *connCreateAcceptedTLS(int fd, int require_auth) {
711 tls_connection *conn = (tls_connection *) createTLSConnection(0);
712 conn->c.fd = fd;
713 conn->c.state = CONN_STATE_ACCEPTING;
714
715 if (!conn->ssl) {
716 updateTLSError(conn);
717 conn->c.state = CONN_STATE_ERROR;
718 return (connection *) conn;
719 }
720
721 switch (require_auth) {
722 case TLS_CLIENT_AUTH_NO:
723 SSL_set_verify(conn->ssl, SSL_VERIFY_NONE, NULL);
724 break;
725 case TLS_CLIENT_AUTH_OPTIONAL:
726 SSL_set_verify(conn->ssl, SSL_VERIFY_PEER, NULL);
727 break;
728 default: /* TLS_CLIENT_AUTH_YES, also fall-secure */
729 SSL_set_verify(conn->ssl, SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL);
730 break;
731 }
732
733 SSL_set_fd(conn->ssl, conn->c.fd);
734 SSL_set_accept_state(conn->ssl);
735
736 return (connection *) conn;
737}
738
739static void tlsEventHandler(struct aeEventLoop *el, int fd, void *clientData, int mask);
740

Callers 2

clusterAcceptHandlerFunction · 0.85
acceptTLSHandlerFunction · 0.85

Calls 2

createTLSConnectionFunction · 0.85
updateTLSErrorFunction · 0.85

Tested by

no test coverage detected