Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix schannel issues #578

Merged
merged 4 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/rpc/requestrouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ SPECIALIZE_FORMATTER_FOR_QDEBUG(QNetworkProxy)
SPECIALIZE_FORMATTER_FOR_QDEBUG(QSslError)

namespace fmt {
template<>
struct formatter<QSslCertificate> : tremotesf::SimpleFormatter {
fmt::format_context::iterator format(const QSslCertificate& certificate, fmt::format_context& ctx) const {
// QSslCertificate::toText is implemented only for OpenSSL backend
#if QT_VERSION_MAJOR >= 6
using tremotesf::operator""_l1;
static const bool isOpenSSL = (QSslSocket::activeBackend() == "openssl"_l1);
if (!isOpenSSL) {
return tremotesf::impl::QDebugFormatter<QSslCertificate>{}.format(certificate, ctx);
}
#endif
return fmt::formatter<QString>{}.format(certificate.toText(), ctx);
}
};

template<>
struct formatter<QSsl::SslProtocol> : tremotesf::SimpleFormatter {
fmt::format_context::iterator format(QSsl::SslProtocol protocol, fmt::format_context& ctx) const {
Expand Down Expand Up @@ -165,7 +180,7 @@ namespace tremotesf::impl {
i,
sslError.error(),
sslError.errorString(),
sslError.certificate().toText()
sslError.certificate()
));
++i;
}
Expand Down Expand Up @@ -212,11 +227,12 @@ namespace tremotesf::impl {
mSslConfiguration.setPrivateKey(mConfiguration->clientPrivateKey);
}
mExpectedSslErrors.clear();
mExpectedSslErrors.reserve(mConfiguration->serverCertificateChain.size() * 3);
mExpectedSslErrors.reserve(mConfiguration->serverCertificateChain.size() * 4);
for (const auto& certificate : mConfiguration->serverCertificateChain) {
mExpectedSslErrors.push_back(QSslError(QSslError::HostNameMismatch, certificate));
mExpectedSslErrors.push_back(QSslError(QSslError::SelfSignedCertificate, certificate));
mExpectedSslErrors.push_back(QSslError(QSslError::SelfSignedCertificateInChain, certificate));
mExpectedSslErrors.push_back(QSslError(QSslError::CertificateUntrusted, certificate));
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/rpc/requestrouter_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,12 @@ namespace {
}
const auto error = waitForError("foo"_l1, QByteArray{});
QCOMPARE(error.has_value(), true);
QCOMPARE(error.value(), RpcError::ConnectionError);
if (error.value() == RpcError::TimedOut) {
// Can happen with TLS 1.3
warning().log("Connecting to server requiring client certificate timed out");
} else {
QCOMPARE(error.value(), RpcError::ConnectionError);
}
}

void checkClientCertificateSuccess() {
Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"features": [
{
"name": "openssl",
"platform": "!windows"
"platform": "!(windows & arm64)"
}
]
},
Expand Down
Loading