summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstanda <stokos@suse.de>2014-10-22 16:14:29 +0200
committerRob Crittenden <rcritten@redhat.com>2014-10-22 10:55:48 -0400
commitc027af16af4975bbb0aa7bc509ea059944028481 (patch)
treea7b9dc74178d01a9fd47586d0d42537476a6836f
parentbeb743e0258742cd917f209238e7527d12fa4296 (diff)
downloadmod_nss-c027af16af4975bbb0aa7bc509ea059944028481.tar.gz
mod_nss-c027af16af4975bbb0aa7bc509ea059944028481.tar.xz
mod_nss-c027af16af4975bbb0aa7bc509ea059944028481.zip
Compare subject CN and VS hostname during server start up
-rw-r--r--nss_engine_init.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/nss_engine_init.c b/nss_engine_init.c
index d74f002..2569c8d 100644
--- a/nss_engine_init.c
+++ b/nss_engine_init.c
@@ -1179,12 +1179,20 @@ static void nss_init_certificate(server_rec *s, const char *nickname,
*KEAtype = NSS_FindCertKEAType(*servercert);
+ /* Subject/hostname check */
+ secstatus = CERT_VerifyCertName(*servercert, s->server_hostname);
+ if (secstatus != SECSuccess) {
+ char *cert_dns = CERT_GetCommonName(&(*servercert)->subject);
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
+ "Misconfiguration of certificate's CN and virtual name."
+ " The certificate CN has %s. We expected %s as virtual"
+ " name.", cert_dns, s->server_hostname);
+ PORT_Free(cert_dns);
+ }
+
/*
- * Check for certs that are expired or not yet valid and WARN about it
- * no need to refuse working - the client gets a warning, but can work
- * with the server we could also verify if the certificate is made out
- * for the correct hostname but that would require a reverse DNS lookup
- * for every virtual server - too expensive?
+ * Check for certs that are expired or not yet valid and WARN about it.
+ * No need to refuse working - the client gets a warning.
*/
certtimestatus = CERT_CheckCertValidTimes(*servercert, PR_Now(), PR_FALSE);