mirror of
https://github.com/osmarks/ngircd.git
synced 2025-02-03 02:49:10 +00:00
Cipher list selection for GnuTLS
This patch implements the missing functionality for cipher list selection using GnuTLS (our OpenSSL code has this already).
This commit is contained in:
parent
51231ac8d4
commit
b9006acee3
@ -248,12 +248,16 @@
|
|||||||
# SSL Server Key Certificate
|
# SSL Server Key Certificate
|
||||||
;CertFile = :ETCDIR:/ssl/server-cert.pem
|
;CertFile = :ETCDIR:/ssl/server-cert.pem
|
||||||
|
|
||||||
# Select cipher suites allowed for SSL/TLS connections (OpenSSL only).
|
# Select cipher suites allowed for SSL/TLS connections. This defaults
|
||||||
# This defaults to the empty string, so all supported ciphers are
|
# to the empty string, so all supported ciphers are allowed. Please
|
||||||
# allowed. Please see 'man 1ssl ciphers' for details.
|
# see 'man 1ssl ciphers' (OpenSSL) and 'man 3 gnutls_priority_init'
|
||||||
# The example below only allows "high strength" cipher suites, disables
|
# (GnuTLS) for details.
|
||||||
# the ones without authentication, and sorts by strength:
|
# For example, this setting allows only "high strength" cipher suites,
|
||||||
|
# disables the ones without authentication, and sorts by strength:
|
||||||
|
# For OpenSSL:
|
||||||
;CipherList = HIGH:!aNULL:@STRENGTH
|
;CipherList = HIGH:!aNULL:@STRENGTH
|
||||||
|
# For GnuTLS:
|
||||||
|
;CipherList = SECURE128
|
||||||
|
|
||||||
# Diffie-Hellman parameters
|
# Diffie-Hellman parameters
|
||||||
;DHFile = :ETCDIR:/ssl/dhparams.pem
|
;DHFile = :ETCDIR:/ssl/dhparams.pem
|
||||||
|
@ -367,11 +367,13 @@ when it is compiled with support for SSL using OpenSSL or GnuTLS!
|
|||||||
SSL Certificate file of the private server key.
|
SSL Certificate file of the private server key.
|
||||||
.TP
|
.TP
|
||||||
\fBCipherList\fR (string)
|
\fBCipherList\fR (string)
|
||||||
OpenSSL only: Select cipher suites allowed for SSL/TLS connections. This
|
Select cipher suites allowed for SSL/TLS connections. This defaults to the
|
||||||
defaults to the empty string, so all supported ciphers are allowed. Please see
|
empty string, so all supported ciphers are allowed.
|
||||||
'man 1ssl ciphers' for details. This setting allows only "high strength" cipher
|
Please see 'man 1ssl ciphers' (OpenSSL) and 'man 3 gnutls_priority_init'
|
||||||
suites, disables the ones without authentication, and sorts by strength, for
|
(GnuTLS) for details.
|
||||||
example: "HIGH:!aNULL:@STRENGTH".
|
For example, this setting allows only "high strength" cipher suites, disables
|
||||||
|
the ones without authentication, and sorts by strength:
|
||||||
|
"HIGH:!aNULL:@STRENGTH" (OpenSSL), "SECURE128" (GnuTLS).
|
||||||
.TP
|
.TP
|
||||||
\fBDHFile\fR (string)
|
\fBDHFile\fR (string)
|
||||||
Name of the Diffie-Hellman Parameter file. Can be created with GnuTLS
|
Name of the Diffie-Hellman Parameter file. Can be created with GnuTLS
|
||||||
|
@ -58,6 +58,7 @@ static bool ConnSSL_LoadServerKey_openssl PARAMS(( SSL_CTX *c ));
|
|||||||
|
|
||||||
static gnutls_certificate_credentials_t x509_cred;
|
static gnutls_certificate_credentials_t x509_cred;
|
||||||
static gnutls_dh_params_t dh_params;
|
static gnutls_dh_params_t dh_params;
|
||||||
|
static gnutls_priority_t priorities_cache;
|
||||||
static bool ConnSSL_LoadServerKey_gnutls PARAMS(( void ));
|
static bool ConnSSL_LoadServerKey_gnutls PARAMS(( void ));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -308,12 +309,12 @@ ConnSSL_InitLibrary( void )
|
|||||||
if(Conf_SSLOptions.CipherList && *Conf_SSLOptions.CipherList) {
|
if(Conf_SSLOptions.CipherList && *Conf_SSLOptions.CipherList) {
|
||||||
if(SSL_CTX_set_cipher_list(newctx, Conf_SSLOptions.CipherList) == 0 ) {
|
if(SSL_CTX_set_cipher_list(newctx, Conf_SSLOptions.CipherList) == 0 ) {
|
||||||
Log(LOG_ERR,
|
Log(LOG_ERR,
|
||||||
"Failed to apply SSL cipher list \"%s\"!",
|
"Failed to apply OpenSSL cipher list \"%s\"!",
|
||||||
Conf_SSLOptions.CipherList);
|
Conf_SSLOptions.CipherList);
|
||||||
goto out;
|
goto out;
|
||||||
} else {
|
} else {
|
||||||
Log(LOG_INFO,
|
Log(LOG_INFO,
|
||||||
"Successfully applied SSL cipher list: \"%s\".",
|
"Successfully applied OpenSSL cipher list \"%s\".",
|
||||||
Conf_SSLOptions.CipherList);
|
Conf_SSLOptions.CipherList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -341,29 +342,43 @@ out:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Conf_SSLOptions.CipherList != NULL) {
|
|
||||||
Log(LOG_ERR,
|
|
||||||
"Failed to apply SSL cipher list \"%s\": Not implemented for GnuTLS!",
|
|
||||||
Conf_SSLOptions.CipherList);
|
|
||||||
array_free(&Conf_SSLOptions.ListenPorts);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = gnutls_global_init();
|
err = gnutls_global_init();
|
||||||
if (err) {
|
if (err) {
|
||||||
Log(LOG_ERR, "Failed to initialize GnuTLS: %s",
|
Log(LOG_ERR, "Failed to initialize GnuTLS: %s",
|
||||||
gnutls_strerror(err));
|
gnutls_strerror(err));
|
||||||
array_free(&Conf_SSLOptions.ListenPorts);
|
goto out;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (!ConnSSL_LoadServerKey_gnutls()) {
|
|
||||||
array_free(&Conf_SSLOptions.ListenPorts);
|
if (!ConnSSL_LoadServerKey_gnutls())
|
||||||
return false;
|
goto out;
|
||||||
|
|
||||||
|
if(Conf_SSLOptions.CipherList && *Conf_SSLOptions.CipherList) {
|
||||||
|
err = gnutls_priority_init(&priorities_cache,
|
||||||
|
Conf_SSLOptions.CipherList, NULL);
|
||||||
|
if (err != GNUTLS_E_SUCCESS) {
|
||||||
|
Log(LOG_ERR,
|
||||||
|
"Failed to apply GnuTLS cipher list \"%s\"!",
|
||||||
|
Conf_SSLOptions.CipherList);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
Log(LOG_INFO,
|
||||||
|
"Successfully applied GnuTLS cipher list \"%s\".",
|
||||||
|
Conf_SSLOptions.CipherList);
|
||||||
|
} else {
|
||||||
|
err = gnutls_priority_init(&priorities_cache, "NORMAL", NULL);
|
||||||
|
if (err != GNUTLS_E_SUCCESS) {
|
||||||
|
Log(LOG_ERR,
|
||||||
|
"Failed to apply GnuTLS cipher list \"NORMAL\"!");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(LOG_INFO, "GnuTLS %s initialized.", gnutls_check_version(NULL));
|
Log(LOG_INFO, "GnuTLS %s initialized.", gnutls_check_version(NULL));
|
||||||
initialized = true;
|
initialized = true;
|
||||||
return true;
|
return true;
|
||||||
|
out:
|
||||||
|
array_free(&Conf_SSLOptions.ListenPorts);
|
||||||
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -489,9 +504,9 @@ ConnSSL_Init_SSL(CONNECTION *c)
|
|||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_LIBGNUTLS
|
#ifdef HAVE_LIBGNUTLS
|
||||||
Conn_OPTION_ADD(c, CONN_SSL);
|
Conn_OPTION_ADD(c, CONN_SSL);
|
||||||
ret = gnutls_set_default_priority(c->ssl_state.gnutls_session);
|
ret = gnutls_priority_set(c->ssl_state.gnutls_session, priorities_cache);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
Log(LOG_ERR, "Failed to set GnuTLS default priority: %s",
|
Log(LOG_ERR, "Failed to set GnuTLS session priorities: %s",
|
||||||
gnutls_strerror(ret));
|
gnutls_strerror(ret));
|
||||||
ConnSSL_Free(c);
|
ConnSSL_Free(c);
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user