It's better to include X509v3 Subject Alternative Name with
DNS names also for additional dns hostnames.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15899
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Aug 26 22:00:26 UTC 2025 on atb-devel-224
(cherry picked from commit
499656a05011a462b2e44faea7318a02c847de5e)
void tls_cert_generate(TALLOC_CTX *mem_ctx,
const char *hostname,
+ const char * const *additional_hostnames,
const char *keyfile, const char *certfile,
const char *cafile);
NTSTATUS tstream_tls_params_server(TALLOC_CTX *mem_ctx,
const char *dns_host_name,
+ const char * const *additional_dns_hostnames,
bool enabled,
const char *key_file,
const char *cert_file,
*/
NTSTATUS tstream_tls_params_server(TALLOC_CTX *mem_ctx,
const char *dns_host_name,
+ const char * const *additional_dns_hostnames,
bool enabled,
const char *key_file,
const char *cert_file,
if (!file_exist(ca_file)) {
tls_cert_generate(tlsp, dns_host_name,
+ additional_dns_hostnames,
key_file, cert_file, ca_file);
}
status = tstream_tls_params_server(mem_ctx,
lpcfg_dns_hostname(lp_ctx),
+ lpcfg_additional_dns_hostnames(lp_ctx),
lpcfg_tls_enabled(lp_ctx),
lpcfg_tls_keyfile(frame, lp_ctx),
lpcfg_tls_certfile(frame, lp_ctx),
*/
void tls_cert_generate(TALLOC_CTX *mem_ctx,
const char *hostname,
+ const char * const *additional_hostnames,
const char *keyfile, const char *certfile,
const char *cafile)
{
size_t bufsize;
size_t keyidsize = sizeof(keyid);
time_t activation = time(NULL), expiry = activation + LIFETIME;
+ size_t adhn_idx;
int ret;
if (file_exist(keyfile) || file_exist(certfile) || file_exist(cafile)) {
TLSCHECK(gnutls_x509_crt_set_subject_alt_name(crt, GNUTLS_SAN_DNSNAME,
hostname, strlen(hostname),
GNUTLS_FSAN_SET));
+ for (adhn_idx = 0;
+ additional_hostnames != NULL &&
+ additional_hostnames[adhn_idx] != NULL;
+ adhn_idx++)
+ {
+ const char *adhn = additional_hostnames[adhn_idx];
+
+ TLSCHECK(gnutls_x509_crt_set_subject_alt_name(crt, GNUTLS_SAN_DNSNAME,
+ adhn, strlen(adhn),
+ GNUTLS_FSAN_APPEND));
+ }
TLSCHECK(gnutls_x509_crt_set_key(crt, key));
TLSCHECK(gnutls_x509_crt_set_serial(crt, &serial, sizeof(serial)));
TLSCHECK(gnutls_x509_crt_set_activation_time(crt, activation));