]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Fix ifdef of X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS, and
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 18 Feb 2020 07:33:58 +0000 (08:33 +0100)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 18 Feb 2020 07:33:58 +0000 (08:33 +0100)
Merge branch 'master' into framestreams

1  2 
services/outside_network.c
util/net_help.c

Simple merge
diff --cc util/net_help.c
index 98c92ad866ec16e93f05e977604fd339f10a9462,0869f91f954e3801b3bd23ff380ab7230cffc956..898ebc9004bd7c3acba38d970e231f385420a3b0
@@@ -1217,42 -1191,6 +1217,44 @@@ void* outgoing_ssl_fd(void* sslctx, in
  #endif
  }
  
 +/** set the authname on an SSL structure, SSL* ssl */
 +int set_auth_name_on_ssl(void* ssl, char* auth_name)
 +{
 +      if(!auth_name) return 1;
 +#ifdef HAVE_SSL
 +      (void)SSL_set_tlsext_host_name(ssl, auth_name);
 +#else
 +      (void)ssl;
 +#endif
 +#ifdef HAVE_SSL_SET1_HOST
 +      SSL_set_verify(ssl, SSL_VERIFY_PEER, NULL);
 +      /* setting the hostname makes openssl verify the
 +       * host name in the x509 certificate in the
 +       * SSL connection*/
 +      if(!SSL_set1_host(ssl, auth_name)) {
 +              log_err("SSL_set1_host failed");
 +              return 0;
 +      }
 +#elif defined(HAVE_X509_VERIFY_PARAM_SET1_HOST)
 +      /* openssl 1.0.2 has this function that can be used for
 +       * set1_host like verification */
 +      if(auth_name) {
 +              X509_VERIFY_PARAM* param = SSL_get0_param(ssl);
++#  ifdef X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS
 +              X509_VERIFY_PARAM_set_hostflags(param, X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS);
++#  endif
 +              if(!X509_VERIFY_PARAM_set1_host(param, auth_name, strlen(auth_name))) {
 +                      log_err("X509_VERIFY_PARAM_set1_host failed");
 +                      return 0;
 +              }
 +              SSL_set_verify(ssl, SSL_VERIFY_PEER, NULL);
 +      }
 +#else
 +      verbose(VERB_ALGO, "the query has an auth_name, but libssl has no call to perform TLS authentication");
 +#endif /* HAVE_SSL_SET1_HOST */
 +      return 1;
 +}
 +
  #if defined(HAVE_SSL) && defined(OPENSSL_THREADS) && !defined(THREADS_DISABLED) && defined(CRYPTO_LOCK) && OPENSSL_VERSION_NUMBER < 0x10100000L
  /** global lock list for openssl locks */
  static lock_basic_type *ub_openssl_locks = NULL;