mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
- enhancement for hardened-tls for DNS over TLS. Removed duplicated
security settings. git-svn-id: file:///svn/unbound/trunk@4255 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
60d4c9bd54
commit
08a3461810
4 changed files with 88 additions and 78 deletions
|
|
@ -229,42 +229,10 @@ daemon_remote_create(struct config_file* cfg)
|
||||||
free(rc);
|
free(rc);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* no SSLv2, SSLv3 because has defects */
|
if(!listen_sslctx_setup(rc->ctx)) {
|
||||||
if((SSL_CTX_set_options(rc->ctx, SSL_OP_NO_SSLv2) & SSL_OP_NO_SSLv2)
|
|
||||||
!= SSL_OP_NO_SSLv2){
|
|
||||||
log_crypto_err("could not set SSL_OP_NO_SSLv2");
|
|
||||||
daemon_remote_delete(rc);
|
daemon_remote_delete(rc);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if((SSL_CTX_set_options(rc->ctx, SSL_OP_NO_SSLv3) & SSL_OP_NO_SSLv3)
|
|
||||||
!= SSL_OP_NO_SSLv3){
|
|
||||||
log_crypto_err("could not set SSL_OP_NO_SSLv3");
|
|
||||||
daemon_remote_delete(rc);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#if defined(SSL_OP_NO_TLSv1) && defined(SSL_OP_NO_TLSv1_1)
|
|
||||||
/* if we have tls 1.1 disable 1.0 */
|
|
||||||
if((SSL_CTX_set_options(rc->ctx, SSL_OP_NO_TLSv1) & SSL_OP_NO_TLSv1)
|
|
||||||
!= SSL_OP_NO_TLSv1){
|
|
||||||
log_crypto_err("could not set SSL_OP_NO_TLSv1");
|
|
||||||
daemon_remote_delete(rc);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if defined(SSL_OP_NO_TLSv1_1) && defined(SSL_OP_NO_TLSv1_2)
|
|
||||||
/* if we have tls 1.2 disable 1.1 */
|
|
||||||
if((SSL_CTX_set_options(rc->ctx, SSL_OP_NO_TLSv1_1) & SSL_OP_NO_TLSv1_1)
|
|
||||||
!= SSL_OP_NO_TLSv1_1){
|
|
||||||
log_crypto_err("could not set SSL_OP_NO_TLSv1_1");
|
|
||||||
daemon_remote_delete(rc);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if defined(SHA256_DIGEST_LENGTH) && defined(USE_ECDSA)
|
|
||||||
/* if we have sha256, set the cipher list to have no known vulns */
|
|
||||||
if(!SSL_CTX_set_cipher_list(rc->ctx, "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256"))
|
|
||||||
log_crypto_err("could not set cipher list with SSL_CTX_set_cipher_list");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (cfg->remote_control_use_cert == 0) {
|
if (cfg->remote_control_use_cert == 0) {
|
||||||
/* No certificates are requested */
|
/* No certificates are requested */
|
||||||
|
|
@ -314,23 +282,7 @@ daemon_remote_create(struct config_file* cfg)
|
||||||
log_crypto_err("Error in SSL_CTX check_private_key");
|
log_crypto_err("Error in SSL_CTX check_private_key");
|
||||||
goto setup_error;
|
goto setup_error;
|
||||||
}
|
}
|
||||||
#if HAVE_DECL_SSL_CTX_SET_ECDH_AUTO
|
listen_sslctx_setup_2(rc->ctx);
|
||||||
if(!SSL_CTX_set_ecdh_auto(rc->ctx,1)) {
|
|
||||||
log_crypto_err("Error in SSL_CTX_ecdh_auto, not enabling ECDHE");
|
|
||||||
}
|
|
||||||
#elif defined(USE_ECDSA)
|
|
||||||
if(1) {
|
|
||||||
EC_KEY *ecdh = EC_KEY_new_by_curve_name (NID_X9_62_prime256v1);
|
|
||||||
if (!ecdh) {
|
|
||||||
log_crypto_err("could not find p256, not enabling ECDHE");
|
|
||||||
} else {
|
|
||||||
if (1 != SSL_CTX_set_tmp_ecdh (rc->ctx, ecdh)) {
|
|
||||||
log_crypto_err("Error in SSL_CTX_set_tmp_ecdh, not enabling ECDHE");
|
|
||||||
}
|
|
||||||
EC_KEY_free (ecdh);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if(!SSL_CTX_load_verify_locations(rc->ctx, s_cert, NULL)) {
|
if(!SSL_CTX_load_verify_locations(rc->ctx, s_cert, NULL)) {
|
||||||
log_crypto_err("Error setting up SSL_CTX verify locations");
|
log_crypto_err("Error setting up SSL_CTX verify locations");
|
||||||
setup_error:
|
setup_error:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
29 June 2017: Wouter
|
29 June 2017: Wouter
|
||||||
- Fix python example0 return module wait instead of error for pass.
|
- Fix python example0 return module wait instead of error for pass.
|
||||||
- iana portlist update
|
- iana portlist update
|
||||||
|
- enhancement for hardened-tls for DNS over TLS. Removed duplicated
|
||||||
|
security settings.
|
||||||
|
|
||||||
27 June 2017: Wouter
|
27 June 2017: Wouter
|
||||||
- Tag 1.6.4 is created with the 1.6.4rc2 contents.
|
- Tag 1.6.4 is created with the 1.6.4rc2 contents.
|
||||||
|
|
|
||||||
|
|
@ -610,6 +610,75 @@ log_crypto_err(const char* str)
|
||||||
#endif /* HAVE_SSL */
|
#endif /* HAVE_SSL */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
listen_sslctx_setup(void* ctxt)
|
||||||
|
{
|
||||||
|
SSL_CTX* ctx = (SSL_CTX*)ctxt;
|
||||||
|
/* no SSLv2, SSLv3 because has defects */
|
||||||
|
if((SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2) & SSL_OP_NO_SSLv2)
|
||||||
|
!= SSL_OP_NO_SSLv2){
|
||||||
|
log_crypto_err("could not set SSL_OP_NO_SSLv2");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if((SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv3) & SSL_OP_NO_SSLv3)
|
||||||
|
!= SSL_OP_NO_SSLv3){
|
||||||
|
log_crypto_err("could not set SSL_OP_NO_SSLv3");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#if defined(SSL_OP_NO_TLSv1) && defined(SSL_OP_NO_TLSv1_1)
|
||||||
|
/* if we have tls 1.1 disable 1.0 */
|
||||||
|
if((SSL_CTX_set_options(ctx, SSL_OP_NO_TLSv1) & SSL_OP_NO_TLSv1)
|
||||||
|
!= SSL_OP_NO_TLSv1){
|
||||||
|
log_crypto_err("could not set SSL_OP_NO_TLSv1");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if defined(SSL_OP_NO_TLSv1_1) && defined(SSL_OP_NO_TLSv1_2)
|
||||||
|
/* if we have tls 1.2 disable 1.1 */
|
||||||
|
if((SSL_CTX_set_options(ctx, SSL_OP_NO_TLSv1_1) & SSL_OP_NO_TLSv1_1)
|
||||||
|
!= SSL_OP_NO_TLSv1_1){
|
||||||
|
log_crypto_err("could not set SSL_OP_NO_TLSv1_1");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if defined(SHA256_DIGEST_LENGTH) && defined(USE_ECDSA)
|
||||||
|
/* if we have sha256, set the cipher list to have no known vulns */
|
||||||
|
if(!SSL_CTX_set_cipher_list(ctx, "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256"))
|
||||||
|
log_crypto_err("could not set cipher list with SSL_CTX_set_cipher_list");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SSL_CTX_set_options(ctx, SSL_OP_CIPHER_SERVER_PREFERENCE);
|
||||||
|
|
||||||
|
#ifdef HAVE_SSL_CTX_SET_SECURITY_LEVEL
|
||||||
|
SSL_CTX_set_security_level(ctx, 0);
|
||||||
|
#endif
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
listen_sslctx_setup_2(void* ctxt)
|
||||||
|
{
|
||||||
|
SSL_CTX* ctx = (SSL_CTX*)ctxt;
|
||||||
|
(void)ctx;
|
||||||
|
#if HAVE_DECL_SSL_CTX_SET_ECDH_AUTO
|
||||||
|
if(!SSL_CTX_set_ecdh_auto(ctx,1)) {
|
||||||
|
log_crypto_err("Error in SSL_CTX_ecdh_auto, not enabling ECDHE");
|
||||||
|
}
|
||||||
|
#elif defined(USE_ECDSA)
|
||||||
|
if(1) {
|
||||||
|
EC_KEY *ecdh = EC_KEY_new_by_curve_name (NID_X9_62_prime256v1);
|
||||||
|
if (!ecdh) {
|
||||||
|
log_crypto_err("could not find p256, not enabling ECDHE");
|
||||||
|
} else {
|
||||||
|
if (1 != SSL_CTX_set_tmp_ecdh (ctx, ecdh)) {
|
||||||
|
log_crypto_err("Error in SSL_CTX_set_tmp_ecdh, not enabling ECDHE");
|
||||||
|
}
|
||||||
|
EC_KEY_free (ecdh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void* listen_sslctx_create(char* key, char* pem, char* verifypem)
|
void* listen_sslctx_create(char* key, char* pem, char* verifypem)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_SSL
|
||||||
|
|
@ -618,16 +687,7 @@ void* listen_sslctx_create(char* key, char* pem, char* verifypem)
|
||||||
log_crypto_err("could not SSL_CTX_new");
|
log_crypto_err("could not SSL_CTX_new");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* no SSLv2, SSLv3 because has defects */
|
if(!listen_sslctx_setup(ctx)) {
|
||||||
if((SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2) & SSL_OP_NO_SSLv2)
|
|
||||||
!= SSL_OP_NO_SSLv2){
|
|
||||||
log_crypto_err("could not set SSL_OP_NO_SSLv2");
|
|
||||||
SSL_CTX_free(ctx);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if((SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv3) & SSL_OP_NO_SSLv3)
|
|
||||||
!= SSL_OP_NO_SSLv3){
|
|
||||||
log_crypto_err("could not set SSL_OP_NO_SSLv3");
|
|
||||||
SSL_CTX_free(ctx);
|
SSL_CTX_free(ctx);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -649,24 +709,7 @@ void* listen_sslctx_create(char* key, char* pem, char* verifypem)
|
||||||
SSL_CTX_free(ctx);
|
SSL_CTX_free(ctx);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#if HAVE_DECL_SSL_CTX_SET_ECDH_AUTO
|
listen_sslctx_setup_2(ctx);
|
||||||
if(!SSL_CTX_set_ecdh_auto(ctx,1)) {
|
|
||||||
log_crypto_err("Error in SSL_CTX_ecdh_auto, not enabling ECDHE");
|
|
||||||
}
|
|
||||||
#elif defined(USE_ECDSA)
|
|
||||||
if(1) {
|
|
||||||
EC_KEY *ecdh = EC_KEY_new_by_curve_name (NID_X9_62_prime256v1);
|
|
||||||
if (!ecdh) {
|
|
||||||
log_crypto_err("could not find p256, not enabling ECDHE");
|
|
||||||
} else {
|
|
||||||
if (1 != SSL_CTX_set_tmp_ecdh (ctx, ecdh)) {
|
|
||||||
log_crypto_err("Error in SSL_CTX_set_tmp_ecdh, not enabling ECDHE");
|
|
||||||
}
|
|
||||||
EC_KEY_free (ecdh);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(verifypem && verifypem[0]) {
|
if(verifypem && verifypem[0]) {
|
||||||
if(!SSL_CTX_load_verify_locations(ctx, verifypem, NULL)) {
|
if(!SSL_CTX_load_verify_locations(ctx, verifypem, NULL)) {
|
||||||
log_crypto_err("Error in SSL_CTX verify locations");
|
log_crypto_err("Error in SSL_CTX verify locations");
|
||||||
|
|
|
||||||
|
|
@ -345,6 +345,19 @@ void sock_list_merge(struct sock_list** list, struct regional* region,
|
||||||
*/
|
*/
|
||||||
void log_crypto_err(const char* str);
|
void log_crypto_err(const char* str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set SSL_OP_NOxxx options on SSL context to disable bad crypto
|
||||||
|
* @param ctxt: SSL_CTX*
|
||||||
|
* @return false on failure.
|
||||||
|
*/
|
||||||
|
int listen_sslctx_setup(void* ctxt);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Further setup of listening SSL context, after keys loaded.
|
||||||
|
* @param ctxt: SSL_CTX*
|
||||||
|
*/
|
||||||
|
void listen_sslctx_setup_2(void* ctxt);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create SSL listen context
|
* create SSL listen context
|
||||||
* @param key: private key file.
|
* @param key: private key file.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue