From 38917d883a4d25aefb07d230497bedbf65fbce33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 4 Aug 2022 09:33:09 +0200 Subject: [PATCH] wip qauthenticator - print extra sspi info Change-Id: Ia919de3292fa4a3546c0310175998514fe6fb9eb --- src/network/kernel/qauthenticator.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 86242b011f..6dfff31c36 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -1568,7 +1568,8 @@ static QByteArray qSspiStartup(QAuthenticatorPrivate *ctx, QAuthenticatorPrivate if (!ctx->sspiWindowsHandles) ctx->sspiWindowsHandles.reset(new QSSPIWindowsHandles); - memset(&ctx->sspiWindowsHandles->credHandle, 0, sizeof(CredHandle)); + SecInvalidateHandle(&ctx->sspiWindowsHandles->credHandle); + SecInvalidateHandle(&ctx->sspiWindowsHandles->ctxHandle); SEC_WINNT_AUTH_IDENTITY auth; auth.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE; @@ -1590,6 +1591,7 @@ static QByteArray qSspiStartup(QAuthenticatorPrivate *ctx, QAuthenticatorPrivate SECPKG_CRED_OUTBOUND, nullptr, useAuth ? &auth : nullptr, nullptr, nullptr, &ctx->sspiWindowsHandles->credHandle, &expiry ); + qErrnoWarning("qSspiStartup::AcquireCredentialsHandle:: secStatus: %x"); if (secStatus != SEC_E_OK) { ctx->sspiWindowsHandles.reset(nullptr); return QByteArray(); @@ -1632,6 +1634,10 @@ static QByteArray qSspiContinue(QAuthenticatorPrivate *ctx, QAuthenticatorPrivat std::wstring targetNameW = (method == QAuthenticatorPrivate::Negotiate ? QLatin1String("HTTP/") + host : QString()).toStdWString(); + qWarning() << "challenge.size:" << challenge.size(); + if (challenge.size() >= 5) + qWarning() << "challenge:" << challenge.left(5); + // Generate our challenge-response message SECURITY_STATUS secStatus = pSecurityFunctionTable->InitializeSecurityContext( &ctx->sspiWindowsHandles->credHandle, @@ -1644,10 +1650,12 @@ static QByteArray qSspiContinue(QAuthenticatorPrivate *ctx, QAuthenticatorPrivat &responseDesc, &attrs, &expiry ); + qErrnoWarning("qSspiContinue::InitializeSecurityContext:: secStatus %x", secStatus); if (secStatus == SEC_I_COMPLETE_NEEDED || secStatus == SEC_I_COMPLETE_AND_CONTINUE) { secStatus = pSecurityFunctionTable->CompleteAuthToken(&ctx->sspiWindowsHandles->ctxHandle, &responseDesc); + qErrnoWarning("SSPI CompleteAuthToken returned %x", secStatus); } if (secStatus != SEC_I_COMPLETE_AND_CONTINUE && secStatus != SEC_I_CONTINUE_NEEDED) { @@ -1656,6 +1664,10 @@ static QByteArray qSspiContinue(QAuthenticatorPrivate *ctx, QAuthenticatorPrivat ctx->sspiWindowsHandles.reset(nullptr); } + qDebug() << "responseDesc.cBuffers" << responseDesc.cBuffers + << "\nresponseBuf.cbBuffer" << responseBuf.cbBuffer + << "\nresponseBuf.BufferType:" << responseBuf.BufferType; + result = QByteArray((const char*)responseBuf.pvBuffer, responseBuf.cbBuffer); pSecurityFunctionTable->FreeContextBuffer(responseBuf.pvBuffer); -- 2.37.1.windows.1