Skip to content

Commit

Permalink
get environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
alfred2g committed Jun 14, 2024
1 parent 2380f9e commit adb7b43
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions source/windows/secure_channel_tls_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -2108,19 +2108,28 @@ static struct aws_channel_handler *s_tls_handler_new(
return NULL;
}

static bool s_is_testing_deprecated_schannel_creds_defined()
{
DWORD ret;
char buffer[10];

/* Used for testing: if defined to any value, we run the deprecarted SCHANNEL_CREDS on newer windows versions */
ret = GetEnvironmentVariable("TEST_DEPRECATED_SCHANNEL_CREDS", buffer, 10);
if (ret != 0) {
AWS_LOGF_DEBUG(
AWS_LS_IO_TLS, "Variable TEST_DEPRECATED_SCHANNEL_CREDS is defined testing deprecated structure");
return true;
}
return false;
}

struct aws_channel_handler *aws_tls_client_handler_new(
struct aws_allocator *allocator,
struct aws_tls_connection_options *options,
struct aws_channel_slot *slot) {
DWORD ret;
char buffer[10];

if (s_is_windows_equal_or_above_10()) {
/* Used for testing: if defined to any value, we run the deprecarted SCHANNEL_CREDS on newer windows versions */
ret = GetEnvironmentVariable("TEST_DEPRECATED_SCHANNEL_CREDS", buffer, 10);
if (ret != 0) {
AWS_LOGF_DEBUG(
AWS_LS_IO_TLS, "Variable TEST_DEPRECATED_SCHANNEL_CREDS is defined testing deprecated structure");
if (s_is_testing_deprecated_schannel_creds_defined()) {
return s_tls_handler_new(allocator, options, slot, true);
}
return s_tls_handler_support_sch_credentials(allocator, options, slot, true);
Expand All @@ -2133,15 +2142,9 @@ struct aws_channel_handler *aws_tls_server_handler_new(
struct aws_allocator *allocator,
struct aws_tls_connection_options *options,
struct aws_channel_slot *slot) {
DWORD ret;
char buffer[10];

if (s_is_windows_equal_or_above_10()) {
/* Used for testing: if defined to any value, we run the deprecarted SCHANNEL_CREDS on newer windows versions */
ret = GetEnvironmentVariable("TEST_DEPRECATED_SCHANNEL_CREDS", buffer, 10);
if (ret != 0) {
AWS_LOGF_DEBUG(
AWS_LS_IO_TLS, "Variable TEST_DEPRECATED_SCHANNEL_CREDS is defined testing deprecated structure");
if (s_is_testing_deprecated_schannel_creds_defined()) {
return s_tls_handler_new(allocator, options, slot, false);
}
return s_tls_handler_support_sch_credentials(allocator, options, slot, false);
Expand Down

0 comments on commit adb7b43

Please sign in to comment.