[crypto,key] add function to export PEM and create a key

* freerdp_key_generate creates a new key
* freerdp_key_get_pem exports the key as PEM
This commit is contained in:
akallabeth
2025-04-22 10:56:13 +02:00
parent 0eefdbdb40
commit 2fb2e5f9c5
10 changed files with 192 additions and 19 deletions

View File

@@ -376,7 +376,7 @@ static void* mf_peer_main_loop(void* arg)
WINPR_ASSERT(settings);
/* Initialize the real server settings here */
rdpPrivateKey* key = freerdp_key_new_from_file(info->key);
rdpPrivateKey* key = freerdp_key_new_from_file_enc(info->key, NULL);
if (!key)
goto fail;
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_RdpServerRsaKey, key, 1))

View File

@@ -1115,7 +1115,7 @@ static DWORD WINAPI test_peer_mainloop(LPVOID arg)
goto fail;
}
rdpPrivateKey* key = freerdp_key_new_from_file(info->key);
rdpPrivateKey* key = freerdp_key_new_from_file_enc(info->key, NULL);
if (!key)
goto fail;
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_RdpServerRsaKey, key, 1))

View File

@@ -255,7 +255,7 @@ static BOOL wf_peer_read_settings(freerdp_peer* client)
&(PrivateKeyFile)))
PrivateKeyFile = _strdup("server.key");
rdpPrivateKey* key = freerdp_key_new_from_file(PrivateKeyFile);
rdpPrivateKey* key = freerdp_key_new_from_file_enc(PrivateKeyFile, NULL);
free(PrivateKeyFile);
if (!key)

View File

@@ -480,7 +480,7 @@ static BOOL pf_server_initialize_peer_connection(freerdp_peer* peer)
pdata->module = server->module;
const proxyConfig* config = pdata->config = server->config;
rdpPrivateKey* key = freerdp_key_new_from_pem(config->PrivateKeyPEM);
rdpPrivateKey* key = freerdp_key_new_from_pem_enc(config->PrivateKeyPEM, NULL);
if (!key)
return FALSE;

View File

@@ -925,7 +925,7 @@ static BOOL shadow_server_init_certificate(rdpShadowServer* server)
rdpSettings* settings = server->settings;
WINPR_ASSERT(settings);
rdpPrivateKey* key = freerdp_key_new_from_file(server->PrivateKeyFile);
rdpPrivateKey* key = freerdp_key_new_from_file_enc(server->PrivateKeyFile, NULL);
if (!key)
goto out_fail;
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_RdpServerRsaKey, key, 1))