diff options
author | nelson%bolyard.com <devnull@localhost> | 2010-08-22 20:59:01 +0000 |
---|---|---|
committer | nelson%bolyard.com <devnull@localhost> | 2010-08-22 20:59:01 +0000 |
commit | 61be6e25e5337e6bcdd1bc279a2c5a2f8f1cc362 (patch) | |
tree | 5e820849b3d1151e280908f385e7a2bddc410473 /security/nss/lib/certdb | |
parent | 08610b146afa0fe18b2856355c08680ad391f3ba (diff) | |
download | nss-hg-61be6e25e5337e6bcdd1bc279a2c5a2f8f1cc362.tar.gz |
Bug 578697: Wildcards and IP addresses don't mix.
Diffstat (limited to 'security/nss/lib/certdb')
-rw-r--r-- | security/nss/lib/certdb/certdb.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/security/nss/lib/certdb/certdb.c b/security/nss/lib/certdb/certdb.c index 1b65b69d8..9fe4c36ef 100644 --- a/security/nss/lib/certdb/certdb.c +++ b/security/nss/lib/certdb/certdb.c @@ -1415,6 +1415,15 @@ sec_lower_string(char *s) return; } +static PRBool +cert_IsIPAddr(const char *hn) +{ + PRBool isIPaddr = PR_FALSE; + PRNetAddr netAddr; + isIPaddr = (PR_SUCCESS == PR_StringToNetAddr(hn, &netAddr)); + return isIPaddr; +} + /* ** Add a domain name to the list of names that the user has explicitly ** allowed (despite cert name mismatches) for use with a server cert. @@ -1880,7 +1889,17 @@ CERT_VerifyCertName(CERTCertificate *cert, const char *hn) cn = CERT_GetCommonName(&cert->subject); if ( cn ) { - rv = cert_TestHostName(cn, hn); + PRBool isIPaddr = cert_IsIPAddr(hn); + if (isIPaddr) { + if (PORT_Strcasecmp(hn, cn) == 0) { + rv = SECSuccess; + } else { + PORT_SetError(SSL_ERROR_BAD_CERT_DOMAIN); + rv = SECFailure; + } + } else { + rv = cert_TestHostName(cn, hn); + } PORT_Free(cn); } else PORT_SetError(SSL_ERROR_BAD_CERT_DOMAIN); |