QSslCertificate: deprecate alternateSubjectNames()
... and add a new method subjectAlternativeNames() instead. This was a typo in the API. Change-Id: Id8704c387c9ff8e1af2b9a524ff628f5c053a294 Reviewed-on: http://codereview.qt.nokia.com/2618 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
This commit is contained in:
parent
69d6012de4
commit
8ef86d05f1
4
dist/changes-5.0.0
vendored
4
dist/changes-5.0.0
vendored
@ -20,6 +20,10 @@ information about a particular change.
|
||||
- QLibrary::resolve() now returns a function pointer instead of a void
|
||||
pointer.
|
||||
|
||||
- QSslCertificate::alternateSubjectNames() is deprecated (but can be enabled
|
||||
via QT_DISABLE_DEPRECATED_BEFORE), use
|
||||
QSslCertificate::subjectAlternativeNames() instead.
|
||||
|
||||
****************************************************************************
|
||||
* General *
|
||||
****************************************************************************
|
||||
|
@ -82,9 +82,9 @@ QT_BEGIN_NAMESPACE
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QSsl::AlternateNameEntryType
|
||||
\enum QSsl::AlternativeNameEntryType
|
||||
|
||||
Describes the key types for alternate name entries in QSslCertificate.
|
||||
Describes the key types for alternative name entries in QSslCertificate.
|
||||
|
||||
\value EmailEntry An email entry; the entry contains an email address that
|
||||
the certificate is valid for.
|
||||
@ -92,7 +92,7 @@ QT_BEGIN_NAMESPACE
|
||||
\value DnsEntry A DNS host name entry; the entry contains a host name
|
||||
entry that the certificate is valid for. The entry may contain wildcards.
|
||||
|
||||
\sa QSslCertificate::alternateSubjectNames()
|
||||
\sa QSslCertificate::subjectAlternativeNames()
|
||||
|
||||
*/
|
||||
|
||||
|
@ -67,11 +67,15 @@ namespace QSsl {
|
||||
Dsa
|
||||
};
|
||||
|
||||
enum AlternateNameEntryType {
|
||||
enum AlternativeNameEntryType {
|
||||
EmailEntry,
|
||||
DnsEntry
|
||||
};
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5,0)
|
||||
typedef AlternativeNameEntryType AlternateNameEntryType;
|
||||
#endif
|
||||
|
||||
enum SslProtocol {
|
||||
SslV3,
|
||||
SslV2,
|
||||
|
@ -426,7 +426,7 @@ QList<QByteArray> QSslCertificate::issuerInfoAttributes() const
|
||||
|
||||
/*!
|
||||
Returns the list of alternative subject names for this
|
||||
certificate. The alternate subject names typically contain host
|
||||
certificate. The alternative names typically contain host
|
||||
names, optionally with wildcards, that are valid for this
|
||||
certificate.
|
||||
|
||||
@ -437,9 +437,9 @@ QList<QByteArray> QSslCertificate::issuerInfoAttributes() const
|
||||
|
||||
\sa subjectInfo()
|
||||
*/
|
||||
QMultiMap<QSsl::AlternateNameEntryType, QString> QSslCertificate::alternateSubjectNames() const
|
||||
QMultiMap<QSsl::AlternativeNameEntryType, QString> QSslCertificate::subjectAlternativeNames() const
|
||||
{
|
||||
QMultiMap<QSsl::AlternateNameEntryType, QString> result;
|
||||
QMultiMap<QSsl::AlternativeNameEntryType, QString> result;
|
||||
|
||||
if (!d->x509)
|
||||
return result;
|
||||
@ -922,7 +922,7 @@ QDebug operator<<(QDebug debug, const QSslCertificate &certificate)
|
||||
<< ',' << certificate.digest().toBase64()
|
||||
<< ',' << certificate.issuerInfo(QSslCertificate::Organization)
|
||||
<< ',' << certificate.subjectInfo(QSslCertificate::Organization)
|
||||
<< ',' << certificate.alternateSubjectNames()
|
||||
<< ',' << certificate.subjectAlternativeNames()
|
||||
#ifndef QT_NO_TEXTSTREAM
|
||||
<< ',' << certificate.effectiveDate()
|
||||
<< ',' << certificate.expiryDate()
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <QtCore/qcryptographichash.h>
|
||||
#include <QtCore/qregexp.h>
|
||||
#include <QtCore/qsharedpointer.h>
|
||||
#include <QtCore/qmap.h>
|
||||
#include <QtNetwork/qssl.h>
|
||||
|
||||
typedef struct x509_st X509; // ### check if this works
|
||||
@ -65,7 +66,6 @@ class QIODevice;
|
||||
class QSslError;
|
||||
class QSslKey;
|
||||
class QStringList;
|
||||
template <typename T, typename U> class QMultiMap;
|
||||
|
||||
class QSslCertificatePrivate;
|
||||
class Q_NETWORK_EXPORT QSslCertificate
|
||||
@ -106,7 +106,11 @@ public:
|
||||
QStringList subjectInfo(const QByteArray &attribute) const;
|
||||
QList<QByteArray> subjectInfoAttributes() const;
|
||||
QList<QByteArray> issuerInfoAttributes() const;
|
||||
QMultiMap<QSsl::AlternateNameEntryType, QString> alternateSubjectNames() const;
|
||||
#if QT_DEPRECATED_SINCE(5,0)
|
||||
QT_DEPRECATED inline QMultiMap<QSsl::AlternateNameEntryType, QString>
|
||||
alternateSubjectNames() const { return subjectAlternativeNames(); }
|
||||
#endif
|
||||
QMultiMap<QSsl::AlternativeNameEntryType, QString> subjectAlternativeNames() const;
|
||||
QDateTime effectiveDate() const;
|
||||
QDateTime expiryDate() const;
|
||||
QSslKey publicKey() const;
|
||||
|
@ -1435,7 +1435,7 @@ bool QSslSocketBackendPrivate::isMatchingHostname(const QSslCertificate &cert, c
|
||||
}
|
||||
}
|
||||
|
||||
foreach (const QString &altName, cert.alternateSubjectNames().values(QSsl::DnsEntry)) {
|
||||
foreach (const QString &altName, cert.subjectAlternativeNames().values(QSsl::DnsEntry)) {
|
||||
if (isMatchingHostname(altName.toLower(), peerName.toLower())) {
|
||||
return true;
|
||||
}
|
||||
|
@ -95,9 +95,9 @@ private slots:
|
||||
void copyAndAssign();
|
||||
void digest_data();
|
||||
void digest();
|
||||
void alternateSubjectNames_data();
|
||||
void subjectAlternativeNames_data();
|
||||
void utf8SubjectNames();
|
||||
void alternateSubjectNames();
|
||||
void subjectAlternativeNames();
|
||||
void publicKey_data();
|
||||
void publicKey();
|
||||
void toPemOrDer_data();
|
||||
@ -203,7 +203,7 @@ void tst_QSslCertificate::emptyConstructor()
|
||||
QCOMPARE(certificate.digest(), QCryptographicHash::hash(QByteArray(), QCryptographicHash::Md5));
|
||||
QCOMPARE(certificate.issuerInfo(QSslCertificate::Organization), QStringList());
|
||||
QCOMPARE(certificate.subjectInfo(QSslCertificate::Organization), QStringList());
|
||||
QCOMPARE(certificate.alternateSubjectNames(),(QMultiMap<QSsl::AlternateNameEntryType, QString>()));
|
||||
QCOMPARE(certificate.subjectAlternativeNames(),(QMultiMap<QSsl::AlternativeNameEntryType, QString>()));
|
||||
#ifndef QT_NO_TEXTSTREAM
|
||||
QCOMPARE(certificate.effectiveDate(), QDateTime());
|
||||
QCOMPARE(certificate.expiryDate(), QDateTime());
|
||||
@ -272,7 +272,7 @@ void tst_QSslCertificate::compareCertificates(
|
||||
QCOMPARE(cert1.issuerInfo(subjectInfo), cert2.issuerInfo(subjectInfo));
|
||||
QCOMPARE(cert1.subjectInfo(subjectInfo), cert2.subjectInfo(subjectInfo));
|
||||
}
|
||||
QCOMPARE(cert1.alternateSubjectNames(), cert2.alternateSubjectNames());
|
||||
QCOMPARE(cert1.subjectAlternativeNames(), cert2.subjectAlternativeNames());
|
||||
QCOMPARE(cert1.effectiveDate(), cert2.effectiveDate());
|
||||
QCOMPARE(cert1.expiryDate(), cert2.expiryDate());
|
||||
QCOMPARE(cert1.version(), cert2.version());
|
||||
@ -352,7 +352,7 @@ void tst_QSslCertificate::digest()
|
||||
certificate.digest(QCryptographicHash::Sha1));
|
||||
}
|
||||
|
||||
void tst_QSslCertificate::alternateSubjectNames_data()
|
||||
void tst_QSslCertificate::subjectAlternativeNames_data()
|
||||
{
|
||||
QTest::addColumn<QString>("certFilePath");
|
||||
QTest::addColumn<QSsl::EncodingFormat>("format");
|
||||
@ -368,7 +368,7 @@ void tst_QSslCertificate::alternateSubjectNames_data()
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QSslCertificate::alternateSubjectNames()
|
||||
void tst_QSslCertificate::subjectAlternativeNames()
|
||||
{
|
||||
if (!QSslSocket::supportsSsl())
|
||||
return;
|
||||
@ -383,11 +383,11 @@ void tst_QSslCertificate::alternateSubjectNames()
|
||||
|
||||
QByteArray fileContents = readFile(subjAltNameFilePath);
|
||||
|
||||
const QMultiMap<QSsl::AlternateNameEntryType, QString> altSubjectNames =
|
||||
certificate.alternateSubjectNames();
|
||||
const QMultiMap<QSsl::AlternativeNameEntryType, QString> altSubjectNames =
|
||||
certificate.subjectAlternativeNames();
|
||||
|
||||
// verify that each entry in subjAltNames is present in fileContents
|
||||
QMapIterator<QSsl::AlternateNameEntryType, QString> it(altSubjectNames);
|
||||
QMapIterator<QSsl::AlternativeNameEntryType, QString> it(altSubjectNames);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
QString type;
|
||||
@ -404,7 +404,7 @@ void tst_QSslCertificate::alternateSubjectNames()
|
||||
// verify that each entry in fileContents is present in subjAltNames
|
||||
QRegExp rx(QLatin1String("(email|DNS):([^,\\r\\n]+)"));
|
||||
for (int pos = 0; (pos = rx.indexIn(fileContents, pos)) != -1; pos += rx.matchedLength()) {
|
||||
QSsl::AlternateNameEntryType key;
|
||||
QSsl::AlternativeNameEntryType key;
|
||||
if (rx.cap(1) == QLatin1String("email"))
|
||||
key = QSsl::EmailEntry;
|
||||
else if (rx.cap(1) == QLatin1String("DNS"))
|
||||
@ -811,7 +811,7 @@ void tst_QSslCertificate::nulInSan()
|
||||
const QSslCertificate &cert = certList.at(0);
|
||||
QVERIFY(!cert.isNull());
|
||||
|
||||
QMultiMap<QSsl::AlternateNameEntryType, QString> san = cert.alternateSubjectNames();
|
||||
QMultiMap<QSsl::AlternativeNameEntryType, QString> san = cert.subjectAlternativeNames();
|
||||
QVERIFY(!san.isEmpty());
|
||||
|
||||
QString dnssan = san.value(QSsl::DnsEntry);
|
||||
|
Loading…
x
Reference in New Issue
Block a user