Skip to content

Commit

Permalink
* Add a small hack to reveal the underlying OpenSSL error in issue #37.
Browse files Browse the repository at this point in the history
  • Loading branch information
iProgramMC committed May 16, 2024
1 parent 312a2cc commit 24a5b98
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions deps/httplib/httplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#ifndef CPPHTTPLIB_HTTPLIB_H
#define CPPHTTPLIB_HTTPLIB_H

extern int g_latestSSLError; // HACK - To debug an "SSL connection failed" issue.

#ifdef MINGW_SPECIFIC_HACKS // iProgramInCpp
#define _REMOVE_IPV6
#define HCRYPTPROV_LEGACY HCRYPTPROV
Expand Down Expand Up @@ -7535,6 +7537,8 @@ bool ssl_connect_or_accept_nonblocking(socket_t sock, SSL *ssl,
break;
default: break;
}
// To debug an issue, setting a global:
g_latestSSLError = err;
return false;
}
return true;
Expand Down
12 changes: 11 additions & 1 deletion src/windows/Frontend_Win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,19 @@ void Frontend_Win32::OnStartTyping(Snowflake userID, Snowflake guildID, Snowflak
SendMessage(g_Hwnd, WM_STARTTYPING, 0, (LPARAM)&parms);
}

extern int g_latestSSLError; // HACK -- defined by the NetworkerThread. Used to debug an issue.

void Frontend_Win32::OnGenericError(const std::string& message)
{
LPCTSTR pMsgBoxText = ConvertCppStringToTString(message);
std::string newMsg = message;
if (g_latestSSLError) {
char buff[128];
snprintf(buff, sizeof buff, "\n\nAdditionally, an SSL error code of 0x%x was provided. Consider sending this to iProgramInCpp!");
newMsg += std::string(buff);
g_latestSSLError = 0;
}

LPCTSTR pMsgBoxText = ConvertCppStringToTString(newMsg);
MessageBox(g_Hwnd, pMsgBoxText, TEXT("Discord Messenger Error"), MB_OK | MB_ICONERROR);
free((void*)pMsgBoxText);
pMsgBoxText = NULL;
Expand Down
2 changes: 2 additions & 0 deletions src/windows/NetworkerThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ extern HWND g_Hwnd;
static NetworkerThread::nmutex g_sslErrorMutex;
static bool g_bQuittingFromSSLError;

int g_latestSSLError = 1; // HACK - used by httplib.h, to debug some weird issue

int NetRequest::Priority() const
{
int prio = 0;
Expand Down

0 comments on commit 24a5b98

Please sign in to comment.