*Dimitri John Ledkov*
+ * SSL_CTX_is_server() was added.
+
+ *Igor Ustinov*
+
OpenSSL 3.5
-----------
=head1 NAME
SSL_client_version, SSL_get_version, SSL_is_dtls, SSL_is_tls, SSL_is_quic,
-SSL_CTX_is_quic, SSL_version - get the protocol information of a connection
+SSL_CTX_is_quic, SSL_CTX_is_server, SSL_version - get the protocol information
+of a connection
=head1 SYNOPSIS
int SSL_is_tls(const SSL *ssl);
int SSL_is_quic(const SSL *ssl);
int SSL_CTX_is_quic(const SSL_CTX *ctx);
+ int SSL_CTX_is_server(const SSL_CTX *ctx);
int SSL_version(const SSL *s);
SSL_CTX_is_quic() returns 1 if the ctx creates QUIC SSL objects or 0 if not.
+SSL_CTX_is_server() returns 1 if the ctx uses a I<method> that allows it to be
+a server (i.e. server-only or generic method) or 0 if not.
+
=head1 RETURN VALUES
The SSL_is_dtls() function was added in OpenSSL 1.1.0. The SSL_is_tls() and
SSL_is_quic() functions were added in OpenSSL 3.2.
-The SSL_CTX_is_quic() function was added in OpenSSL 4.0
+The SSL_CTX_is_quic() and SSL_CTX_is_server() functions were added in
+OpenSSL 4.0
=head1 COPYRIGHT
int SSL_is_tls(const SSL *s);
int SSL_is_quic(const SSL *s);
int SSL_CTX_is_quic(const SSL_CTX *c);
+int SSL_CTX_is_server(const SSL_CTX *c);
__owur int SSL_set_session_id_context(SSL *ssl, const unsigned char *sid_ctx,
unsigned int sid_ctx_len);
return IS_QUIC_CTX(c);
}
+int SSL_CTX_is_server(const SSL_CTX *c)
+{
+ if (c == NULL || c->method == NULL)
+ return 0;
+ return (c->method->ssl_accept == ssl_undefined_function) ? 0 : 1;
+}
+
int SSL_up_ref(SSL *s)
{
int i;
return testresult;
}
+/*
+ * Test that SSL_CTX_is_server returns the expected results.
+ */
+static int test_ssl_ctx_is_server(void)
+{
+ int testresult = 0;
+ SSL_CTX *cctx = NULL, *sctx = NULL, *gctx = NULL;
+
+ cctx = SSL_CTX_new_ex(libctx, NULL, TLS_client_method());
+ sctx = SSL_CTX_new_ex(libctx, NULL, TLS_server_method());
+ gctx = SSL_CTX_new_ex(libctx, NULL, TLS_method());
+
+ if (!TEST_ptr(cctx) || !TEST_ptr(sctx) || !TEST_ptr(gctx))
+ goto end;
+
+ if (!TEST_false(SSL_CTX_is_server(cctx))
+ || !TEST_true(SSL_CTX_is_server(sctx))
+ || !TEST_true(SSL_CTX_is_server(gctx)))
+ goto end;
+
+ testresult = 1;
+end:
+ SSL_CTX_free(cctx);
+ SSL_CTX_free(sctx);
+ SSL_CTX_free(gctx);
+ return testresult;
+}
+
/*
* Test that the SSL_rstate_string*() APIs return sane results
*/
ADD_ALL_TESTS(test_serverinfo_custom, 4);
#endif
ADD_ALL_TESTS(test_version, 6);
+ ADD_TEST(test_ssl_ctx_is_server);
ADD_TEST(test_rstate_string);
ADD_ALL_TESTS(test_handshake_retry, 16);
ADD_TEST(test_data_retry);
SSL_set_quic_tls_transport_params ? 4_0_0 EXIST::FUNCTION:
SSL_set_quic_tls_early_data_enabled ? 4_0_0 EXIST::FUNCTION:
SSL_CTX_is_quic ? 4_0_0 EXIST::FUNCTION:
+SSL_CTX_is_server ? 4_0_0 EXIST::FUNCTION:
OSSL_QUIC_method ? 4_0_0 EXIST::FUNCTION:QUIC
SSL_listen_ex ? 4_0_0 EXIST::FUNCTION: