MCPcopy Create free account
hub / github.com/F-Stack/f-stack / connCreateAcceptedTLS

Function connCreateAcceptedTLS

app/redis-6.2.6/src/tls.c:448–475  ·  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

446 * is not in an error state.
447 */
448connection *connCreateAcceptedTLS(int fd, int require_auth) {
449 tls_connection *conn = (tls_connection *) createTLSConnection(0);
450 conn->c.fd = fd;
451 conn->c.state = CONN_STATE_ACCEPTING;
452
453 if (!conn->ssl) {
454 updateTLSError(conn);
455 conn->c.state = CONN_STATE_ERROR;
456 return (connection *) conn;
457 }
458
459 switch (require_auth) {
460 case TLS_CLIENT_AUTH_NO:
461 SSL_set_verify(conn->ssl, SSL_VERIFY_NONE, NULL);
462 break;
463 case TLS_CLIENT_AUTH_OPTIONAL:
464 SSL_set_verify(conn->ssl, SSL_VERIFY_PEER, NULL);
465 break;
466 default: /* TLS_CLIENT_AUTH_YES, also fall-secure */
467 SSL_set_verify(conn->ssl, SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL);
468 break;
469 }
470
471 SSL_set_fd(conn->ssl, conn->c.fd);
472 SSL_set_accept_state(conn->ssl);
473
474 return (connection *) conn;
475}
476
477static void tlsEventHandler(struct aeEventLoop *el, int fd, void *clientData, int mask);
478

Callers 2

acceptTLSHandlerFunction · 0.85
clusterAcceptHandlerFunction · 0.85

Calls 2

createTLSConnectionFunction · 0.85
updateTLSErrorFunction · 0.85

Tested by

no test coverage detected