/*
* ngIRCd -- The Next Generation IRC Daemon
- *
- * SSL wrapper functions.
* Copyright (c) 2005-2008 Florian Westphal <fw@strlen.de>
*/
#include "portab.h"
+
+/**
+ * @file
+ * SSL wrapper functions
+ */
+
#include "imp.h"
#include "conf-ssl.h"
#include <unistd.h>
#include <gnutls/x509.h>
-#define DH_BITS 1024
+#define DH_BITS 2048
+#define DH_BITS_MIN 1024
+
static gnutls_certificate_credentials_t x509_cred;
static gnutls_dh_params_t dh_params;
-
static bool ConnSSL_LoadServerKey_gnutls PARAMS(( void ));
#endif
bool
ConnSSL_InitLibrary( void )
{
+ if (!array_bytes(&Conf_SSLOptions.ListenPorts))
+ return true;
+
#ifdef HAVE_LIBSSL
SSL_CTX *newctx;
* According to OpenSSL RAND_egd(3): "The automatic query of /var/run/egd-pool et al was added in OpenSSL 0.9.7";
* so it makes little sense to deal with PRNGD seeding ourselves.
*/
+ array_free(&Conf_SSLOptions.ListenPorts);
return false;
}
newctx = SSL_CTX_new(SSLv23_method());
if (!newctx) {
LogOpenSSLError("SSL_CTX_new()", NULL);
+ array_free(&Conf_SSLOptions.ListenPorts);
return false;
}
return true;
out:
SSL_CTX_free(newctx);
+ array_free(&Conf_SSLOptions.ListenPorts);
return false;
#endif
#ifdef HAVE_LIBGNUTLS
err = gnutls_global_init();
if (err) {
Log(LOG_ERR, "gnutls_global_init(): %s", gnutls_strerror(err));
+ array_free(&Conf_SSLOptions.ListenPorts);
return false;
}
- if (!ConnSSL_LoadServerKey_gnutls())
+ if (!ConnSSL_LoadServerKey_gnutls()) {
+ array_free(&Conf_SSLOptions.ListenPorts);
return false;
+ }
Log(LOG_INFO, "gnutls %s initialized.", gnutls_check_version(NULL));
initialized = true;
return true;
cert_file = Conf_SSLOptions.CertFile ? Conf_SSLOptions.CertFile:Conf_SSLOptions.KeyFile;
if (!cert_file) {
- Log(LOG_NOTICE, "No SSL server key configured, SSL disabled.");
+ Log(LOG_ERR, "No SSL server key configured!");
return false;
}
assert(ctx);
if (!Conf_SSLOptions.KeyFile) {
- Log(LOG_NOTICE, "No SSL server key configured, SSL disabled.");
+ Log(LOG_ERR, "No SSL server key configured!");
return false;
}
ConnSSL_Free(c);
return false;
}
- gnutls_dh_set_prime_bits(c->ssl_state.gnutls_session, DH_BITS);
+ gnutls_dh_set_prime_bits(c->ssl_state.gnutls_session, DH_BITS_MIN);
#endif
Conn_OPTION_ADD(c, CONN_SSL);
return true;
assert(ssl);
- Log(LOG_INFO, "New %s connection using cipher %s on socket %d.",
- SSL_get_version(ssl), SSL_get_cipher(ssl), c->sock);
+ Log(LOG_INFO, "Connection %d: initialized %s using cipher %s.",
+ c->sock, SSL_get_version(ssl), SSL_get_cipher(ssl));
#endif
#ifdef HAVE_LIBGNUTLS
gnutls_session_t sess = c->ssl_state.gnutls_session;
gnutls_cipher_algorithm_t cipher = gnutls_cipher_get(sess);
- Log(LOG_INFO, "New %s connection using cipher %s-%s on socket %d.",
+ Log(LOG_INFO, "Connection %d: initialized %s using cipher %s-%s.",
+ c->sock,
gnutls_protocol_get_name(gnutls_protocol_get_version(sess)),
gnutls_cipher_get_name(cipher),
- gnutls_mac_get_name(gnutls_mac_get(sess)), c->sock);
+ gnutls_mac_get_name(gnutls_mac_get(sess)));
#endif
}
#endif /* _GNUTLS */
Conn_OPTION_DEL(c, (CONN_SSL_WANT_WRITE|CONN_SSL_WANT_READ|CONN_SSL_CONNECT));
ConnSSL_LogCertInfo(c);
+
+ Conn_StartLogin(CONNECTION2ID(c));
return 1;
}