Skip to content
Draft
Prev Previous commit
Next Next commit
[core,credssp] implement credssp.json
  • Loading branch information
akallabeth committed Oct 1, 2026
commit 71b2d241bcccf8765d846a2b3da0a49bf4062216
24 changes: 23 additions & 1 deletion libfreerdp/core/credssp_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "settings.h"
#include <freerdp/build-config.h>
#include <freerdp/peer.h>
#include <freerdp/utils/helpers.h>
#include <winpr/config-readers.h>

#include <winpr/crt.h>
#include <winpr/wtypes.h>
Expand Down Expand Up @@ -73,6 +75,8 @@ struct rdp_credssp_auth
char* pkgNameA;
};

static const char credssp_config_file_name[] = "credssp.json";

static const char* credssp_auth_state_string(const rdpCredsspAuth* auth)
{
WINPR_ASSERT(auth);
Expand Down Expand Up @@ -848,14 +852,25 @@ void credssp_auth_free(rdpCredsspAuth* auth)
free(auth);
}

static void auth_get_sspi_module_from_config(char** sspi_module)
{
WINPR_ASSERT(sspi_module);

WINPR_JSON* json = freerdp_GetJSONConfigFile(TRUE, credssp_config_file_name);
if (!json)
return;

winpr_config_apply_string(credssp_config_file_name, json, "SspiModule", sspi_module);
WINPR_JSON_Delete(json);
}

static void auth_get_sspi_module_from_reg(char** sspi_module)
{
HKEY hKey = nullptr;
DWORD dwType = 0;
DWORD dwSize = 0;

WINPR_ASSERT(sspi_module);
*sspi_module = nullptr;

char* key = freerdp_getApplicatonDetailsRegKey(SERVER_KEY);
if (!key)
Expand All @@ -867,6 +882,8 @@ static void auth_get_sspi_module_from_reg(char** sspi_module)
if (rc != ERROR_SUCCESS)
return;

WLog_WARN(TAG, "HKLM.reg is deprecated since 3.33.0. ATTENTION: Use %s instead!",
credssp_config_file_name);
if (RegQueryValueExA(hKey, "SspiModule", nullptr, &dwType, nullptr, &dwSize) != ERROR_SUCCESS)
{
RegCloseKey(hKey);
Expand All @@ -889,6 +906,8 @@ static void auth_get_sspi_module_from_reg(char** sspi_module)
}

RegCloseKey(hKey);

free(*sspi_module);
*sspi_module = module;
}

Expand All @@ -899,7 +918,10 @@ static SecurityFunctionTable* auth_resolve_sspi_table(const rdpSettings* setting
WINPR_ASSERT(settings);

if (settings->ServerMode)
{
auth_get_sspi_module_from_reg(&sspi_module);
auth_get_sspi_module_from_config(&sspi_module);
}

if (sspi_module || settings->SspiModule)
{
Expand Down