| 
									
										
										
										
											2020-04-21 01:57:23 +04:30
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2021-04-23 00:43:01 +04:30
										 |  |  |  * Copyright (c) 2020, Ali Mohammad Pur <mpfard@serenityos.org> | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  |  * Copyright (c) 2025, Altomani Gianluca <altomanigianluca@gmail.com> | 
					
						
							| 
									
										
										
										
											2020-04-21 01:57:23 +04:30
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-04-21 01:57:23 +04:30
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  | #include <LibCore/Promise.h>
 | 
					
						
							|  |  |  | #include <LibCrypto/OpenSSL.h>
 | 
					
						
							| 
									
										
										
										
											2020-04-21 01:57:23 +04:30
										 |  |  | #include <LibTLS/TLSv12.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  | #include <openssl/bio.h>
 | 
					
						
							|  |  |  | #include <openssl/err.h>
 | 
					
						
							|  |  |  | #include <openssl/ssl.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-01 17:11:35 +02:00
										 |  |  | namespace TLS { | 
					
						
							| 
									
										
										
										
											2023-03-21 18:48:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  | ErrorOr<NonnullOwnPtr<TLSv12>> TLSv12::connect(ByteString const& host, u16 port, Options options) | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  |     auto tcp_socket = TRY(Core::TCPSocket::connect(host, port)); | 
					
						
							| 
									
										
										
										
											2025-02-22 12:42:48 +01:00
										 |  |  |     return connect_internal(move(tcp_socket), host, move(options)); | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-22 12:42:48 +01:00
										 |  |  | ErrorOr<NonnullOwnPtr<TLSv12>> TLSv12::connect(Core::SocketAddress const& address, ByteString const& host, Options options) | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     auto tcp_socket = TRY(Core::TCPSocket::connect(address)); | 
					
						
							| 
									
										
										
										
											2025-02-22 12:42:48 +01:00
										 |  |  |     return connect_internal(move(tcp_socket), host, move(options)); | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-19 14:20:26 +01:00
										 |  |  | static void wait_for_activity(int sock, bool read) | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     fd_set fds; | 
					
						
							|  |  |  |     FD_ZERO(&fds); | 
					
						
							|  |  |  |     FD_SET(sock, &fds); | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  |     if (read) | 
					
						
							|  |  |  |         select(sock + 1, &fds, nullptr, nullptr, nullptr); | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |         select(sock + 1, nullptr, &fds, nullptr, nullptr); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-22 12:44:22 +01:00
										 |  |  | void TLSv12::handle_fatal_error() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // If this error occurs then no further I/O operations should be performed
 | 
					
						
							|  |  |  |     // on the connection and SSL_shutdown() must not be called.
 | 
					
						
							|  |  |  |     SSL_free(m_ssl); | 
					
						
							|  |  |  |     m_ssl = nullptr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_socket->close(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  | ErrorOr<Bytes> TLSv12::read_some(Bytes bytes) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2025-02-22 12:44:22 +01:00
										 |  |  |     if (!m_ssl) | 
					
						
							|  |  |  |         return Error::from_string_literal("SSL connection is closed"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-22 12:38:48 +01:00
										 |  |  |     auto ret = SSL_read(m_ssl, bytes.data(), bytes.size()); | 
					
						
							|  |  |  |     if (ret <= 0) { | 
					
						
							| 
									
										
										
										
											2025-02-22 12:44:22 +01:00
										 |  |  |         switch (SSL_get_error(m_ssl, ret)) { | 
					
						
							| 
									
										
										
										
											2025-02-22 12:38:48 +01:00
										 |  |  |         case SSL_ERROR_ZERO_RETURN: | 
					
						
							|  |  |  |             return Bytes { bytes.data(), 0 }; | 
					
						
							|  |  |  |         case SSL_ERROR_WANT_READ: | 
					
						
							|  |  |  |         case SSL_ERROR_WANT_WRITE: | 
					
						
							|  |  |  |             return Error::from_errno(EAGAIN); | 
					
						
							| 
									
										
										
										
											2025-02-22 12:44:22 +01:00
										 |  |  |         case SSL_ERROR_SSL: | 
					
						
							|  |  |  |             handle_fatal_error(); | 
					
						
							|  |  |  |             ERR_print_errors_cb(openssl_print_errors, nullptr); | 
					
						
							|  |  |  |             return Error::from_string_literal("Fatal SSL error reading from SSL connection"); | 
					
						
							|  |  |  |         case SSL_ERROR_SYSCALL: | 
					
						
							|  |  |  |             handle_fatal_error(); | 
					
						
							|  |  |  |             return Error::from_errno(errno); | 
					
						
							| 
									
										
										
										
											2025-02-22 12:38:48 +01:00
										 |  |  |         default: | 
					
						
							| 
									
										
										
										
											2025-02-22 12:44:22 +01:00
										 |  |  |             return Error::from_string_literal("Failed reading from SSL connection"); | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-02-22 12:38:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return Bytes { bytes.data(), static_cast<unsigned long>(ret) }; | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  | ErrorOr<size_t> TLSv12::write_some(ReadonlyBytes bytes) | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-02-22 12:44:22 +01:00
										 |  |  |     if (!m_ssl) | 
					
						
							|  |  |  |         return Error::from_string_literal("SSL connection is closed"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-22 12:38:48 +01:00
										 |  |  |     auto ret = SSL_write(m_ssl, bytes.data(), bytes.size()); | 
					
						
							|  |  |  |     if (ret <= 0) { | 
					
						
							| 
									
										
										
										
											2025-02-22 12:44:22 +01:00
										 |  |  |         switch (SSL_get_error(m_ssl, ret)) { | 
					
						
							| 
									
										
										
										
											2025-02-22 12:38:48 +01:00
										 |  |  |         case SSL_ERROR_WANT_READ: | 
					
						
							|  |  |  |         case SSL_ERROR_WANT_WRITE: | 
					
						
							|  |  |  |             return Error::from_errno(EAGAIN); | 
					
						
							| 
									
										
										
										
											2025-02-22 12:44:22 +01:00
										 |  |  |         case SSL_ERROR_SSL: | 
					
						
							|  |  |  |             handle_fatal_error(); | 
					
						
							|  |  |  |             ERR_print_errors_cb(openssl_print_errors, nullptr); | 
					
						
							|  |  |  |             return Error::from_string_literal("Fatal SSL error writing to SSL connection"); | 
					
						
							|  |  |  |         case SSL_ERROR_SYSCALL: | 
					
						
							|  |  |  |             handle_fatal_error(); | 
					
						
							|  |  |  |             return Error::from_errno(errno); | 
					
						
							| 
									
										
										
										
											2025-02-22 12:38:48 +01:00
										 |  |  |         default: | 
					
						
							| 
									
										
										
										
											2025-02-22 12:44:22 +01:00
										 |  |  |             return Error::from_string_literal("Failed writing to SSL connection"); | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-02-22 12:38:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return ret; | 
					
						
							| 
									
										
										
										
											2020-05-05 13:24:00 +04:30
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-05-18 20:16:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  | bool TLSv12::is_eof() const | 
					
						
							| 
									
										
										
										
											2020-10-30 11:56:31 +03:30
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-02-22 12:44:22 +01:00
										 |  |  |     return m_socket->is_eof(); | 
					
						
							| 
									
										
										
										
											2020-10-30 11:56:31 +03:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  | bool TLSv12::is_open() const | 
					
						
							| 
									
										
										
										
											2022-03-15 19:16:44 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-02-22 12:44:22 +01:00
										 |  |  |     return m_socket->is_open(); | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-03-15 19:16:44 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  | void TLSv12::close() | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-02-22 12:44:22 +01:00
										 |  |  |     if (m_ssl) | 
					
						
							|  |  |  |         SSL_shutdown(m_ssl); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_socket->close(); | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  | ErrorOr<size_t> TLSv12::pending_bytes() const | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-02-22 12:44:22 +01:00
										 |  |  |     if (!m_ssl) | 
					
						
							|  |  |  |         return Error::from_string_literal("SSL connection is closed"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  |     return SSL_pending(m_ssl); | 
					
						
							| 
									
										
										
										
											2022-02-21 22:25:34 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-18 13:04:17 +01:00
										 |  |  | ErrorOr<bool> TLSv12::can_read_without_blocking(int timeout) const | 
					
						
							| 
									
										
										
										
											2022-02-21 22:25:34 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-02-22 12:44:22 +01:00
										 |  |  |     if (!m_ssl) | 
					
						
							|  |  |  |         return Error::from_string_literal("SSL connection is closed"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-18 13:04:17 +01:00
										 |  |  |     return m_socket->can_read_without_blocking(timeout); | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-19 14:20:26 +01:00
										 |  |  | ErrorOr<void> TLSv12::set_blocking(bool) | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-02-19 14:20:26 +01:00
										 |  |  |     return Error::from_string_literal("Blocking mode cannot be changed after the SSL connection is established"); | 
					
						
							| 
									
										
										
										
											2020-10-30 11:56:31 +03:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  | ErrorOr<void> TLSv12::set_close_on_exec(bool enabled) | 
					
						
							| 
									
										
										
										
											2020-10-30 11:56:31 +03:30
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  |     return m_socket->set_close_on_exec(enabled); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-04 10:58:41 +02:00
										 |  |  | TLSv12::TLSv12(NonnullOwnPtr<Core::TCPSocket> socket, SSL_CTX* ssl_ctx, SSL* ssl) | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  |     : m_ssl_ctx(ssl_ctx) | 
					
						
							|  |  |  |     , m_ssl(ssl) | 
					
						
							|  |  |  |     , m_socket(move(socket)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_socket->on_ready_to_read = [this] { | 
					
						
							| 
									
										
										
										
											2025-02-22 12:46:50 +01:00
										 |  |  |         // There is something to read on the underlying TCP connection. This doesn't mean there is actual data to read from the SSL connection.
 | 
					
						
							|  |  |  |         // For example, we might have received an alert or a connection reset.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         char buffer[1]; | 
					
						
							|  |  |  |         auto ret = SSL_peek(m_ssl, buffer, 1); | 
					
						
							|  |  |  |         if (ret <= 0) { | 
					
						
							|  |  |  |             switch (SSL_get_error(m_ssl, ret)) { | 
					
						
							|  |  |  |             case SSL_ERROR_SSL: | 
					
						
							|  |  |  |             case SSL_ERROR_SYSCALL: | 
					
						
							|  |  |  |                 handle_fatal_error(); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             default: | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // Now that we handled possible fatal errors, we can notify the user that there is data to read.
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  |         if (on_ready_to_read) | 
					
						
							|  |  |  |             on_ready_to_read(); | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2020-10-30 11:56:31 +03:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  | TLSv12::~TLSv12() | 
					
						
							| 
									
										
										
										
											2021-05-29 08:26:10 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  |     SSL_free(m_ssl); | 
					
						
							|  |  |  |     SSL_CTX_free(m_ssl_ctx); | 
					
						
							| 
									
										
										
										
											2021-05-29 08:26:10 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  | ErrorOr<NonnullOwnPtr<TLSv12>> TLSv12::connect_internal(NonnullOwnPtr<Core::TCPSocket> socket, ByteString const& host, Options options) | 
					
						
							| 
									
										
										
										
											2020-05-18 20:16:52 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-02-19 14:20:26 +01:00
										 |  |  |     TRY(socket->set_blocking(options.blocking)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  |     auto* ssl_ctx = OPENSSL_TRY_PTR(SSL_CTX_new(TLS_client_method())); | 
					
						
							|  |  |  |     ArmedScopeGuard free_ssl_ctx = [&] { SSL_CTX_free(ssl_ctx); }; | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  |     // Configure the client to abort the handshake if certificate verification fails.
 | 
					
						
							|  |  |  |     SSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_PEER, nullptr); | 
					
						
							| 
									
										
										
										
											2020-05-18 20:16:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  |     if (options.root_certificates_path.has_value()) { | 
					
						
							|  |  |  |         auto path = options.root_certificates_path.value(); | 
					
						
							|  |  |  |         SSL_CTX_load_verify_file(ssl_ctx, path.characters()); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         // Use the default trusted certificate store
 | 
					
						
							|  |  |  |         OPENSSL_TRY(SSL_CTX_set_default_verify_paths(ssl_ctx)); | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  |     // Require a minimum TLS version of TLSv1.2.
 | 
					
						
							|  |  |  |     OPENSSL_TRY(SSL_CTX_set_min_proto_version(ssl_ctx, TLS1_2_VERSION)); | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  |     auto* ssl = OPENSSL_TRY_PTR(SSL_new(ssl_ctx)); | 
					
						
							|  |  |  |     ArmedScopeGuard free_ssl = [&] { SSL_free(ssl); }; | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  |     // Tell the server which hostname we are attempting to connect to in case the server supports multiple hosts.
 | 
					
						
							|  |  |  |     OPENSSL_TRY(SSL_set_tlsext_host_name(ssl, host.characters())); | 
					
						
							| 
									
										
										
										
											2024-07-06 23:12:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  |     // Ensure we check that the server has supplied a certificate for the hostname that we were expecting.
 | 
					
						
							|  |  |  |     OPENSSL_TRY(SSL_set1_host(ssl, host.characters())); | 
					
						
							| 
									
										
										
										
											2020-08-02 05:27:42 +04:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  |     auto* bio = OPENSSL_TRY_PTR(BIO_new_socket(socket->fd(), 0)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // SSL takes ownership of the BIO and will handle freeing it
 | 
					
						
							|  |  |  |     SSL_set_bio(ssl, bio, bio); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-19 14:20:26 +01:00
										 |  |  |     while (true) { | 
					
						
							|  |  |  |         auto ret = SSL_connect(ssl); | 
					
						
							|  |  |  |         if (ret == 1) { | 
					
						
							|  |  |  |             // Successfully connected
 | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         switch (SSL_get_error(ssl, ret)) { | 
					
						
							|  |  |  |         case SSL_ERROR_WANT_READ: | 
					
						
							|  |  |  |             wait_for_activity(socket->fd(), true); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case SSL_ERROR_WANT_WRITE: | 
					
						
							|  |  |  |             wait_for_activity(socket->fd(), false); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case SSL_ERROR_SSL: | 
					
						
							|  |  |  |             ERR_print_errors_cb(openssl_print_errors, nullptr); | 
					
						
							|  |  |  |             return Error::from_string_literal("Fatal SSL error connecting to SSL server"); | 
					
						
							|  |  |  |         case SSL_ERROR_SYSCALL: | 
					
						
							|  |  |  |             return Error::from_errno(errno); | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             return Error::from_string_literal("Failed connecting to SSL server"); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-02-14 09:49:33 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     free_ssl.disarm(); | 
					
						
							|  |  |  |     free_ssl_ctx.disarm(); | 
					
						
							| 
									
										
										
										
											2024-11-24 21:39:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-04 10:58:41 +02:00
										 |  |  |     return adopt_own(*new TLSv12(move(socket), ssl_ctx, ssl)); | 
					
						
							| 
									
										
										
										
											2024-11-24 21:39:56 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-21 01:57:23 +04:30
										 |  |  | } |