Revert "Add workaround for broken TLS SNI in Windows 8.1 for the archive updater"

This reverts commit 9b657018c6e5e5024141fee1ef4c96e5389bfefb.
This commit is contained in:
palana 2014-03-05 18:12:33 +01:00
parent 9b657018c6
commit 0545b4ad0f
4 changed files with 7 additions and 49 deletions

View File

@ -20,21 +20,7 @@
#include "Main.h"
#include <winhttp.h>
__declspec(thread) bool invalidCN = false;
static void CALLBACK WinHTTPStatusCallback(HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength)
{
if (dwStatusInformationLength != 4)
return;
if ((*(DWORD*)lpvStatusInformation) & ~(WINHTTP_CALLBACK_STATUS_FLAG_CERT_CN_INVALID | WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CA))
return;
if ((*(DWORD*)lpvStatusInformation) & WINHTTP_CALLBACK_STATUS_FLAG_CERT_CN_INVALID)
invalidCN = true;
}
BOOL HTTPGetFile(CTSTR url, CTSTR outputPath, CTSTR extraHeaders, int *responseCode, HTTPGetFileWin81TLSSNIBugHandler h)
BOOL HTTPGetFile (CTSTR url, CTSTR outputPath, CTSTR extraHeaders, int *responseCode)
{
HINTERNET hSession = NULL;
HINTERNET hConnect = NULL;
@ -68,14 +54,10 @@ BOOL HTTPGetFile(CTSTR url, CTSTR outputPath, CTSTR extraHeaders, int *responseC
if (urlComponents.nPort == 443)
secure = TRUE;
retry:
hSession = WinHttpOpen(OBS_VERSION_STRING, WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
if (!hSession)
goto failure;
if (secure)
WinHttpSetStatusCallback(hSession, WinHTTPStatusCallback, WINHTTP_CALLBACK_FLAG_SECURE_FAILURE, NULL);
hConnect = WinHttpConnect(hSession, hostName, secure ? INTERNET_DEFAULT_HTTPS_PORT : INTERNET_DEFAULT_HTTP_PORT, 0);
if (!hConnect)
goto failure;
@ -86,20 +68,11 @@ retry:
BOOL bResults = WinHttpSendRequest(hRequest, extraHeaders, extraHeaders ? -1 : 0, WINHTTP_NO_REQUEST_DATA, 0, 0, 0);
if (!bResults)
{
DWORD err = GetLastError();
if (err == ERROR_WINHTTP_SECURE_FAILURE && invalidCN && h && h())
{
secure = 0;
WinHttpSetStatusCallback(hSession, nullptr, WINHTTP_CALLBACK_FLAG_SECURE_FAILURE, NULL);
goto retry;
}
goto failure;
}
// End the request.
bResults = WinHttpReceiveResponse(hRequest, NULL);
if (bResults)
bResults = WinHttpReceiveResponse(hRequest, NULL);
else
goto failure;
TCHAR statusCode[8];
DWORD statusCodeLen;
@ -148,10 +121,7 @@ retry:
failure:
if (hSession)
{
WinHttpSetStatusCallback(hSession, nullptr, WINHTTP_CALLBACK_FLAG_SECURE_FAILURE, NULL);
WinHttpCloseHandle(hSession);
}
if (hConnect)
WinHttpCloseHandle(hConnect);
if (hRequest)

View File

@ -19,8 +19,6 @@
#pragma once
typedef bool(HTTPGetFileWin81TLSSNIBugHandler)();
BOOL HTTPGetFile(CTSTR url, CTSTR outputPath, CTSTR extraHeaders, int *responseCode, HTTPGetFileWin81TLSSNIBugHandler h = nullptr);
BOOL HTTPGetFile (CTSTR url, CTSTR outputPath, CTSTR extraHeaders, int *responseCode);
String CreateHTTPURL(String host, String path, String extra=String(), bool secure=false);

View File

@ -99,7 +99,7 @@ BOOL CalculateFileHash (TCHAR *path, BYTE *hash)
#define MANIFEST_URL "https://builds.catchexception.org/update.json"
#define UPDATER_PATH "/updates/org.catchexception.builds.updater.exe"
#define UPDATE_CHANNEL "master"
//*/
*/
#ifndef MANIFEST_WITH_ARCHIVES
#define MANIFEST_WITH_ARCHIVES 0
@ -372,11 +372,6 @@ bool ParseUpdateManifest (TCHAR *path, BOOL *updatesAvailable, String &descripti
#endif
}
bool Win81TLSSNIBugHandler()
{
return OSGetVersion() == 8 && OBSMessageBox(hwndMain, Str("Updater.Win81TLSSNIBug"), nullptr, MB_YESNOCANCEL | MB_DEFBUTTON2) == IDYES;
}
DWORD WINAPI CheckUpdateThread (VOID *arg)
{
int responseCode;
@ -426,11 +421,7 @@ DWORD WINAPI CheckUpdateThread (VOID *arg)
scat(extraHeaders, strGUID);
}
#if MANIFEST_WITH_ARCHIVES
if (HTTPGetFile(TEXT(MANIFEST_URL), manifestPath, extraHeaders, &responseCode, Win81TLSSNIBugHandler))
#else
if (HTTPGetFile(TEXT(MANIFEST_URL), manifestPath, extraHeaders, &responseCode))
#endif
{
if (responseCode == 200 || responseCode == 304)
{

View File

@ -381,7 +381,6 @@ Updater.NewUpdates="The following updates are available:\r\n\r\n"
Updater.RunningWarning="OBS will be restarted to install the updates.\r\n\r\nAre you sure you want to continue?"
Updater.UpdatesAvailable="Updates are available"
Updater.NoUpdatesAvailable="No updates are available"
Updater.Win81TLSSNIBug="Due to a bug in Windows 8.1 the secure update check failed. Do you want to retry the update check via an insecure connection?"
MainMenu.Help.LogFiles="Log Files"
MainMenu.Help.AnalyzeCurrentLog="Analyze current Log File"