Ensure that we can match on subject altnames, as well as the CN.

Also update the documentation to indicate the behaviour.

There might be a case for adding a bool argument to matchesHostname()
so that you can test if it matches just the CN, or either CN or
altname. 

This function should probably also test IP address (and perhaps also
XMPP) altnames, but I'd like to think about that a bit more first, and
trial it with a real certificate.

CCMAIL: justin@affinix.com
CCBUG: 107604


svn path=/trunk/kdesupport/qca/; revision=540564
This commit is contained in:
Brad Hards 2006-05-14 00:55:35 +00:00
parent 1fba679d79
commit ddc49c5291
2 changed files with 6 additions and 1 deletions

View File

@ -524,6 +524,10 @@ namespace QCA
/**
Test if the subject of the certificate matches a specified host name
This will return true (indicating a match), if the
specified host name matches either the CommonName,
or an alternative name specified in the certificate.
\param host the name of the host to compare to
*/
bool matchesHostname(const QString &host) const;

View File

@ -455,7 +455,8 @@ bool Certificate::matchesHostname(const QString &realHost) const
peerHost.truncate(peerHost.length()-1);
peerHost = peerHost.toLower();
if(cnMatchesAddress(commonName(), peerHost))
if(cnMatchesAddress(commonName(), peerHost) ||
subjectInfo().values(DNS).contains(peerHost) )
return true;
return false;
}