diff options
author | Liang Qi <liang.qi@qt.io> | 2017-06-07 12:05:33 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-06-07 14:02:43 +0200 |
commit | 7cbee5629604aa49c618829c8e3e55fc64e94df7 (patch) | |
tree | d12041105160c1cb21226b365edb9653d87b5853 /src/network/ssl/qsslsocket_mac.cpp | |
parent | e400b7e326c554ccd819448866265953d2a0f24d (diff) | |
parent | 5f0ce2333f7e11a3ffb5d16a27cd9303efa712d5 (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
src/widgets/widgets/qmenu.cpp
Change-Id: I6d3baf56eb24501cddb129a3cb6b958ccc25a308
Diffstat (limited to 'src/network/ssl/qsslsocket_mac.cpp')
-rw-r--r-- | src/network/ssl/qsslsocket_mac.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/network/ssl/qsslsocket_mac.cpp b/src/network/ssl/qsslsocket_mac.cpp index 0456b7cdc7..0a9588deea 100644 --- a/src/network/ssl/qsslsocket_mac.cpp +++ b/src/network/ssl/qsslsocket_mac.cpp @@ -1226,9 +1226,32 @@ bool QSslSocketBackendPrivate::verifyPeerTrust() QCFType<SecCertificateRef> certRef = SecCertificateCreateWithData(NULL, certData); CFArrayAppendValue(certArray, certRef); } + SecTrustSetAnchorCertificates(trust, certArray); - // Secure Transport should use anchors only from our QSslConfiguration: - SecTrustSetAnchorCertificatesOnly(trust, true); + + // By default SecTrustEvaluate uses both CA certificates provided in + // QSslConfiguration and the ones from the system database. This behavior can + // be unexpected if a user's code tries to limit the trusted CAs to those + // explicitly set in QSslConfiguration. + // Since on macOS we initialize the default QSslConfiguration copying the + // system CA certificates (using SecTrustSettingsCopyCertificates) we can + // call SecTrustSetAnchorCertificatesOnly(trust, true) to force SecTrustEvaluate + // to use anchors only from our QSslConfiguration. + // Unfortunately, SecTrustSettingsCopyCertificates is not available on iOS + // and the default QSslConfiguration always has an empty list of system CA + // certificates. This leaves no way to provide client code with access to the + // actual system CA certificate list (which most use-cases need) other than + // by letting SecTrustEvaluate fall through to the system list; so, in this case + // (even though the client code may have provided its own certs), we retain + // the default behavior. + +#ifdef Q_OS_MACOS + const bool anchorsFromConfigurationOnly = true; +#else + const bool anchorsFromConfigurationOnly = false; +#endif + + SecTrustSetAnchorCertificatesOnly(trust, anchorsFromConfigurationOnly); SecTrustResultType trustResult = kSecTrustResultInvalid; SecTrustEvaluate(trust, &trustResult); |