X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fssli_openssl.c;h=0f631d20276a2c1dc0cca6ae5a085c95cdc53e87;hb=779660334a7291f4918e313a78ed48f4d3d6e0a5;hp=65a21deab05b09296e4f6cc1b03e701a234c4259;hpb=82e80f8f18cbb6fed903621751ba9751dc2b80a2;p=umurmur.git diff --git a/src/ssli_openssl.c b/src/ssli_openssl.c index 65a21de..0f631d2 100644 --- a/src/ssli_openssl.c +++ b/src/ssli_openssl.c @@ -33,6 +33,7 @@ #include "conf.h" #include "log.h" +#include "memory.h" #include "ssl.h" /* @@ -48,6 +49,8 @@ static RSA *rsa; static SSL_CTX *context; static EVP_PKEY *pkey; +static char const * ciphers = "EECDH+AESGCM:AES256-SHA:AES128-SHA"; + static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx); static int SSL_add_ext(X509 * crt, int nid, char *value) { @@ -158,7 +161,7 @@ static void SSL_initializeCert() { char *key = (char *)getStrConf(KEY); if (context) { - bool did_load_cert = SSL_CTX_use_certificate_chain_file(context, crt); + bool_t did_load_cert = SSL_CTX_use_certificate_chain_file(context, crt); rsa = SSL_readprivatekey(key); if (!rsa || !did_load_cert) { @@ -220,12 +223,20 @@ void SSLi_init(void) ERR_load_crypto_strings(); context = SSL_CTX_new(SSLv23_server_method()); + SSL_CTX_set_options(context, SSL_OP_NO_SSLv2); + SSL_CTX_set_options(context, SSL_OP_NO_SSLv3); if (context == NULL) { ERR_print_errors_fp(stderr); abort(); } + SSL_CTX_set_cipher_list(context, ciphers); + + EC_KEY *ecdhkey = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); + SSL_CTX_set_tmp_ecdh(context, ecdhkey); + EC_KEY_free(ecdhkey); + char const * sslCAPath = getStrConf(CAPATH); if(sslCAPath != NULL) { @@ -250,9 +261,7 @@ void SSLi_init(void) Log_debug("%s", SSL_CIPHER_get_name(cipher)); cipherstringlen += strlen(SSL_CIPHER_get_name(cipher)) + 1; } - cipherstring = malloc(cipherstringlen + 1); - if (cipherstring == NULL) - Log_fatal("Out of memory"); + cipherstring = Memory_safeMalloc(1, cipherstringlen + 1); for (i = 0; (cipher = sk_SSL_CIPHER_value(cipherlist_new, i)) != NULL; i++) { offset += sprintf(cipherstring + offset, "%s:", SSL_CIPHER_get_name(cipher)); } @@ -328,10 +337,7 @@ bool_t SSLi_getSHA1Hash(SSL_handle_t *ssl, uint8_t *hash) } len = i2d_X509(x509, NULL); - buf = malloc(len); - if (buf == NULL) { - Log_fatal("malloc"); - } + buf = Memory_safeMalloc(1, len); p = buf; i2d_X509(x509, &p);