Add SSL_CTX_get_ciphers()
authorKazuki Yamaguchi <k@rhe.jp>
Sun, 10 Apr 2016 04:18:50 +0000 (13:18 +0900)
committerRich Salz <rsalz@openssl.org>
Mon, 11 Apr 2016 13:59:04 +0000 (09:59 -0400)
Add an accessor for SSL_CTX.

Since libssl was made opaque, there is no way for users to access the
cipher_list, while users can set the cipher_list by
SSL_CTX_set_cipher_list().

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
doc/ssl/SSL_get_ciphers.pod
doc/ssl/ssl.pod
include/openssl/ssl.h
ssl/ssl_lib.c
util/libssl.num

index 5e4bc08dcd6320314d2a23252810b92f46c8ba10..a017392611523cac2b539a69be7e433fb5767acd 100644 (file)
@@ -2,13 +2,14 @@
 
 =head1 NAME
 
-SSL_get_ciphers, SSL_get_cipher_list - get list of available SSL_CIPHERs
+SSL_get_ciphers, SSL_CTX_get_ciphers, SSL_get_cipher_list - get list of available SSL_CIPHERs
 
 =head1 SYNOPSIS
 
  #include <openssl/ssl.h>
 
  STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *ssl);
+ STACK_OF(SSL_CIPHER) *SSL_CTX_get_ciphers(const SSL_CTX *ctx);
  STACK_OF(SSL_CIPHER) *SSL_get1_supported_ciphers(SSL *s);
  STACK_OF(SSL_CIPHER) *SSL_get_client_ciphers(const SSL *ssl);
  const char *SSL_get_cipher_list(const SSL *ssl, int priority);
@@ -19,6 +20,8 @@ SSL_get_ciphers() returns the stack of available SSL_CIPHERs for B<ssl>,
 sorted by preference. If B<ssl> is NULL or no ciphers are available, NULL
 is returned.
 
+SSL_CTX_get_ciphers() returns the stack of available SSL_CIPHERs for B<ctx>.
+
 SSL_get1_supported_ciphers() returns the stack of enabled SSL_CIPHERs for
 B<ssl>, sorted by preference.
 The list depends on settings like the cipher list, the supported protocol
@@ -43,17 +46,17 @@ is returned.
 
 =head1 NOTES
 
-The details of the ciphers obtained by SSL_get_ciphers(),
+The details of the ciphers obtained by SSL_get_ciphers(), SSL_CTX_get_ciphers()
 SSL_get1_supported_ciphers() and SSL_get_client_ciphers() can be obtained using
 the L<SSL_CIPHER_get_name(3)> family of functions.
 
 Call SSL_get_cipher_list() with B<priority> starting from 0 to obtain the
 sorted list of available ciphers, until NULL is returned.
 
-Note: SSL_get_ciphers() and SSL_get_client_ciphers() return a pointer
-to an internal cipher stack, which will be freed later on when the SSL
-or SSL_SESSION object is freed.  Therefore, the calling code B<MUST
-NOT> free the return value itself.
+Note: SSL_get_ciphers(), SSL_CTX_get_ciphers() and SSL_get_client_ciphers()
+return a pointer to an internal cipher stack, which will be freed later on when
+the SSL or SSL_SESSION object is freed.  Therefore, the calling code B<MUST NOT>
+free the return value itself.
 
 The stack returned by SSL_get1_supported_ciphers() should be freed using
 sk_SSL_CIPHER_free().
index c875163248578f4ba3ac254d314aa11e2a5bf69f..7e2cd85ffeadcbd4971eb68ebcf4d182aaca8fe8 100644 (file)
@@ -239,6 +239,8 @@ protocol context defined in the B<SSL_CTX> structure.
 
 =item X509_STORE *B<SSL_CTX_get_cert_store>(SSL_CTX *ctx);
 
+=item STACK *B<SSL_CTX_get_ciphers>(const SSL_CTX *ctx);
+
 =item STACK *B<SSL_CTX_get_client_CA_list>(const SSL_CTX *ctx);
 
 =item int (*B<SSL_CTX_get_client_cert_cb>(SSL_CTX *ctx))(SSL *ssl, X509 **x509, EVP_PKEY **pkey);
index 8459c93e0547e17a32eb6ae43854ea3a306ced40..b085c9ebb202e99c983df13a7d870b09d38a4858 100644 (file)
@@ -1683,6 +1683,7 @@ __owur const SSL_METHOD *DTLS_server_method(void); /* DTLS 1.0 and 1.2 */
 __owur const SSL_METHOD *DTLS_client_method(void); /* DTLS 1.0 and 1.2 */
 
 __owur STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s);
+__owur STACK_OF(SSL_CIPHER) *SSL_CTX_get_ciphers(const SSL_CTX *ctx);
 __owur STACK_OF(SSL_CIPHER) *SSL_get_client_ciphers(const SSL *s);
 __owur STACK_OF(SSL_CIPHER) *SSL_get1_supported_ciphers(SSL *s);
 
index 68fe4965cff59627efe48731302b7fe006091d47..06d972349a9dab25ef1c551b233f35dcb5d38f27 100644 (file)
@@ -1999,6 +1999,15 @@ const char *SSL_get_cipher_list(const SSL *s, int n)
     return (c->name);
 }
 
+/** return a STACK of the ciphers available for the SSL_CTX and in order of
+ * preference */
+STACK_OF(SSL_CIPHER) *SSL_CTX_get_ciphers(const SSL_CTX *ctx)
+{
+    if (ctx != NULL)
+        return ctx->cipher_list;
+    return NULL;
+}
+
 /** specify the ciphers to be used by default by the SSL_CTX */
 int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str)
 {
index 950ca03913ae0b68497a3edfc9ea91ec51fce400..74f2c8aa8d7cef52fb52a4d34ab82785aba450dd 100644 (file)
@@ -392,3 +392,4 @@ SSL_CTX_set0_ctlog_store                391 1_1_0   EXIST::FUNCTION:CT
 SSL_CTX_get0_ctlog_store                392    1_1_0   EXIST::FUNCTION:CT
 SSL_enable_ct                           393    1_1_0   EXIST::FUNCTION:CT
 SSL_CTX_enable_ct                       394    1_1_0   EXIST::FUNCTION:CT
+SSL_CTX_get_ciphers                     395    1_1_0   EXIST::FUNCTION