fix: stop console from breaking after installing cert

This commit is contained in:
2026-03-20 19:19:04 -03:00
parent 1275adb5fd
commit de76e89ed0
+11 -1
View File
@@ -12,6 +12,8 @@
#include <cstdlib>
#include <ctime>
#include <Windows.h>
std::string randomizeString(size_t length)
{
const char charset[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
@@ -131,7 +133,15 @@ bool CertManager::GenerateCA()
Log::info("Generated new CA key and certificate files. Installing to Windows Root CA store automatically...");
system("certutil.exe -user -addstore root ca_cert.pem");
STARTUPINFOA si = {sizeof(si)};
PROCESS_INFORMATION pi;
char cmd[] = "certutil.exe -user -addstore root ca_cert.pem";
if (CreateProcessA(NULL, cmd, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi))
{
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
return true;
}