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. */
| 446 | * is not in an error state. |
| 447 | */ |
| 448 | connection *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 | |
| 477 | static void tlsEventHandler(struct aeEventLoop *el, int fd, void *clientData, int mask); |
| 478 |
no test coverage detected