MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / ssl_new

Function ssl_new

dependencies/httplib/httplib.h:7060–7088  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7058
7059template <typename U, typename V>
7060inline SSL *ssl_new(socket_t sock, SSL_CTX *ctx, std::mutex &ctx_mutex,
7061 U SSL_connect_or_accept, V setup) {
7062 SSL *ssl = nullptr;
7063 {
7064 std::lock_guard<std::mutex> guard(ctx_mutex);
7065 ssl = SSL_new(ctx);
7066 }
7067
7068 if (ssl) {
7069 set_nonblocking(sock, true);
7070 auto bio = BIO_new_socket(static_cast<int>(sock), BIO_NOCLOSE);
7071 BIO_set_nbio(bio, 1);
7072 SSL_set_bio(ssl, bio, bio);
7073
7074 if (!setup(ssl) || SSL_connect_or_accept(ssl) != 1) {
7075 SSL_shutdown(ssl);
7076 {
7077 std::lock_guard<std::mutex> guard(ctx_mutex);
7078 SSL_free(ssl);
7079 }
7080 set_nonblocking(sock, false);
7081 return nullptr;
7082 }
7083 BIO_set_nbio(bio, 0);
7084 set_nonblocking(sock, false);
7085 }
7086
7087 return ssl;
7088}
7089
7090inline void ssl_delete(std::mutex &ctx_mutex, SSL *ssl,
7091 bool shutdown_gracefully) {

Callers 2

initialize_sslMethod · 0.85

Calls 1

set_nonblockingFunction · 0.85

Tested by

no test coverage detected