mirror of https://github.com/FreeRDP/FreeRDP
Options to specify sfreerdp-server cert and private key
This commit is contained in:
parent
ba0da04217
commit
210c56d0fb
|
@ -60,6 +60,8 @@ struct server_info
|
||||||
{
|
{
|
||||||
BOOL test_dump_rfx_realtime;
|
BOOL test_dump_rfx_realtime;
|
||||||
const char* test_pcap_file;
|
const char* test_pcap_file;
|
||||||
|
const char* cert;
|
||||||
|
const char* key;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void test_peer_context_free(freerdp_peer* client, rdpContext* ctx)
|
static void test_peer_context_free(freerdp_peer* client, rdpContext* ctx)
|
||||||
|
@ -877,26 +879,38 @@ static BOOL tf_peer_suppress_output(rdpContext* context, BYTE allow, const RECTA
|
||||||
|
|
||||||
static DWORD WINAPI test_peer_mainloop(LPVOID arg)
|
static DWORD WINAPI test_peer_mainloop(LPVOID arg)
|
||||||
{
|
{
|
||||||
|
BOOL rc;
|
||||||
DWORD error = CHANNEL_RC_OK;
|
DWORD error = CHANNEL_RC_OK;
|
||||||
HANDLE handles[32] = { 0 };
|
HANDLE handles[32] = { 0 };
|
||||||
DWORD count;
|
DWORD count;
|
||||||
DWORD status;
|
DWORD status;
|
||||||
testPeerContext* context;
|
testPeerContext* context;
|
||||||
|
struct server_info* info;
|
||||||
freerdp_peer* client = (freerdp_peer*)arg;
|
freerdp_peer* client = (freerdp_peer*)arg;
|
||||||
|
const char* key = "server.key";
|
||||||
|
const char* cert = "server.crt";
|
||||||
|
|
||||||
WINPR_ASSERT(client);
|
WINPR_ASSERT(client);
|
||||||
|
|
||||||
|
info = client->ContextExtra;
|
||||||
|
WINPR_ASSERT(info);
|
||||||
|
|
||||||
if (!test_peer_init(client))
|
if (!test_peer_init(client))
|
||||||
{
|
{
|
||||||
freerdp_peer_free(client);
|
freerdp_peer_free(client);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (info->key)
|
||||||
|
key = info->key;
|
||||||
|
if (info->cert)
|
||||||
|
cert = info->cert;
|
||||||
|
|
||||||
/* Initialize the real server settings here */
|
/* Initialize the real server settings here */
|
||||||
WINPR_ASSERT(client->settings);
|
WINPR_ASSERT(client->settings);
|
||||||
if (!freerdp_settings_set_string(client->settings, FreeRDP_CertificateFile, "server.crt") ||
|
if (!freerdp_settings_set_string(client->settings, FreeRDP_CertificateFile, cert) ||
|
||||||
!freerdp_settings_set_string(client->settings, FreeRDP_PrivateKeyFile, "server.key") ||
|
!freerdp_settings_set_string(client->settings, FreeRDP_PrivateKeyFile, key) ||
|
||||||
!freerdp_settings_set_string(client->settings, FreeRDP_RdpKeyFile, "server.key"))
|
!freerdp_settings_set_string(client->settings, FreeRDP_RdpKeyFile, key))
|
||||||
{
|
{
|
||||||
WLog_ERR(TAG, "Memory allocation failed (strdup)");
|
WLog_ERR(TAG, "Memory allocation failed (strdup)");
|
||||||
freerdp_peer_free(client);
|
freerdp_peer_free(client);
|
||||||
|
@ -931,7 +945,8 @@ static DWORD WINAPI test_peer_mainloop(LPVOID arg)
|
||||||
client->settings->MultifragMaxRequestSize = 0xFFFFFF; /* FIXME */
|
client->settings->MultifragMaxRequestSize = 0xFFFFFF; /* FIXME */
|
||||||
|
|
||||||
WINPR_ASSERT(client->Initialize);
|
WINPR_ASSERT(client->Initialize);
|
||||||
client->Initialize(client);
|
rc = client->Initialize(client);
|
||||||
|
WINPR_ASSERT(rc);
|
||||||
|
|
||||||
context = (testPeerContext*)client->context;
|
context = (testPeerContext*)client->context;
|
||||||
WINPR_ASSERT(context);
|
WINPR_ASSERT(context);
|
||||||
|
@ -1075,7 +1090,9 @@ static const struct
|
||||||
const char sfast[7];
|
const char sfast[7];
|
||||||
const char sport[7];
|
const char sport[7];
|
||||||
const char slocal_only[13];
|
const char slocal_only[13];
|
||||||
} options = { "--pcap=", "--fast", "--port=", "--local-only" };
|
const char scert[7];
|
||||||
|
const char skey[6];
|
||||||
|
} options = { "--pcap=", "--fast", "--port=", "--local-only", "--cert=", "--key=" };
|
||||||
|
|
||||||
static WINPR_NORETURN(void usage(const char* app, const char* invalid))
|
static WINPR_NORETURN(void usage(const char* app, const char* invalid))
|
||||||
{
|
{
|
||||||
|
@ -1129,6 +1146,18 @@ int main(int argc, char* argv[])
|
||||||
if (!winpr_PathFileExists(info.test_pcap_file))
|
if (!winpr_PathFileExists(info.test_pcap_file))
|
||||||
usage(app, arg);
|
usage(app, arg);
|
||||||
}
|
}
|
||||||
|
else if (strncmp(arg, options.scert, sizeof(options.scert)) == 0)
|
||||||
|
{
|
||||||
|
info.cert = &arg[sizeof(options.scert)];
|
||||||
|
if (!winpr_PathFileExists(info.cert))
|
||||||
|
usage(app, arg);
|
||||||
|
}
|
||||||
|
else if (strncmp(arg, options.skey, sizeof(options.skey)) == 0)
|
||||||
|
{
|
||||||
|
info.key = &arg[sizeof(options.skey)];
|
||||||
|
if (!winpr_PathFileExists(info.key))
|
||||||
|
usage(app, arg);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
usage(app, arg);
|
usage(app, arg);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue