qt5base-lts/tests/auto/network/ssl/qsslcertificate
Marc Mutz e8bdc949fc Add qHash(QSslCertificate) overload
qsslsocket_winrt.cpp defined it locally, which runs the risk of
clashes with a potential user-defined qHash(QSslCertificate), so
make it public.

Also, the implementation in qsslsocket_winrt.cpp simply hashed
the handle(), which violates the principle that equal instances
must hash to the same value. Also, for some platforms, the
implementation returns nullptr unconditionally, which, while not
violating the above-mentioned principle, will make all users of
the hash have worst-case complexity.

To calculate a meaningful hash, therefore, the certificate needs
to be inspected deeper than just the handle.

For OpenSSL, we use X509::sha1_hash, which also X509_cmp uses
internally to determine inequality (it checks more stuff, but
if X059::sha1_hash is different, X509_cmp() returns non-zero,
which is sufficient for the purposes of qHash()). sha1_hash may
not be up-to-date, though, so we call X509_cmp to make it valid.
Ugh.

For WinRT/Qt, we use the DER encoding, as that is the native
storage format used in QSslCertificate. This is not equivalent
to the implementation used in qsslsocket_winrt.cpp before, but
since handle() == handle() => toDer() == toDer(), it should not
be a problem.

[ChangeLog][QtNetwork][QSslCertificate] Can now be used as a key in QSet/QHash.

Change-Id: I10858fe648c70fc9535af6913dd3b7f3b2cf0eba
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
2014-10-19 07:32:37 +02:00
..
certificates Update license headers and add new license files 2014-09-24 12:26:19 +02:00
more-certificates QSslCertificate: blacklist NIC certificates from India 2014-07-09 21:30:11 +02:00
pkcs12 Move the PKCS#12 support from QSslSocket to QSslCertificate. 2014-05-14 11:08:01 +02:00
verify-certs Moved network autotests into new directory structure 2011-09-09 09:32:17 +02:00
.gitignore Moved network autotests into new directory structure 2011-09-09 09:32:17 +02:00
qsslcertificate.pro Move the PKCS#12 support from QSslSocket to QSslCertificate. 2014-05-14 11:08:01 +02:00
tst_qsslcertificate.cpp Add qHash(QSslCertificate) overload 2014-10-19 07:32:37 +02:00