3 ms·
So the way you're using it: auto verificationErrors = reply->sslConfiguration().peerCertificate().verify(m_sslConfiguration.caCertificates()); implies th
by tartboogers 9y ago
So the way you're using it:
auto verificationErrors = reply->sslConfiguration().peerCertificate().verify(m_sslConfiguration.caCertificates());
implies that you want to see if "peerCertificate" validates under "m_sslConfiguration.caCertificates()".
That's a reasonable (and necessary) thing to do, but the "verify" function doesn't do that. It's a static function, thus it ignores "peerCertificate". The way you're using it, it simply verifies "m_sslConfiguration.caCertificates" using the system's default CA certificates (I think; the docs are somewhat confusing about this).
Also, further down in that code, you ignore self-signed errors. Well that pretty much negates the point of checking in the first place doesn't it? Because if someone MITM's your connection with a self-signed certificate, your code will say that's fine.
However, according to the docs for "QSslConfiguration::setCaCertificates", those CA certificates are used to verify the peer certificate during the SSL handshake. So do you even need to be doing any kind of verification manually? I'm not a Qt programmer, but it seems to me that since you're using the appropriate "QSslConfiguration::peerVerifyMode", it should verify the server certificate during the handshake using the CA certificates you set (it happens in the Mac code at [1]).
Bottom line: your "RemoteDatabase::gotEncrypted" function can simply be eliminated. This would both provide proper peer verification and eliminate your problem on the Mac platform.
[1] https://github.com/qt/qtbase/blob/dev/src/network/ssl/qsslsocket_mac.cpp#L1121 https://github.com/qt/qtbase/blob/dev/src/network/ssl/qsslso...
- justinclift 9y ago> Bottom line: your "RemoteDatabase::gotEncrypted" function can simply be eliminated. (and the rest) Awesome! Thank you. :)