Skip to content

Commit bf598f4

Browse files
authored
BYO_CRYPTO test and fix (#337)
1 parent 146f643 commit bf598f4

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ jobs:
7979
aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh
8080
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DBUILD_SHARED_LIBS=ON
8181
82+
byo-crypto:
83+
runs-on: ubuntu-latest
84+
steps:
85+
# We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages
86+
- name: Build ${{ env.PACKAGE_NAME }}
87+
run: |
88+
aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh
89+
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DBYO_CRYPTO=ON downstream
90+
8291
windows:
8392
runs-on: windows-latest
8493
steps:

CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,9 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
9696
COMPONENT Development)
9797

9898
include(CTest)
99-
if (BUILD_TESTING)
99+
if (NOT BYO_CRYPTO AND BUILD_TESTING)
100100
add_subdirectory(tests)
101-
102-
if (NOT CMAKE_CROSSCOMPILING )
101+
if (NOT CMAKE_CROSSCOMPILING)
103102
add_subdirectory(bin/elasticurl)
104103
endif()
105104
endif()

integration-testing/http_client_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import sys
66
import urllib.request
77
import unittest
8+
import os.path
89

910
TIMEOUT = 100
1011

@@ -14,6 +15,13 @@
1415
print('You must pass the elasticurl cmd prefix')
1516
sys.exit(-1)
1617

18+
program_to_run = elasticurl_cmd_prefix[0]
19+
20+
if 'bin' in program_to_run:
21+
if not os.path.exists(program_to_run):
22+
print('the program_to_run is not found, skip integration test')
23+
sys.exit(0)
24+
1725
# Remove args from sys.argv so that unittest doesn't also try to parse them.
1826
sys.argv = sys.argv[:1]
1927

source/proxy_connection.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ AWS_STATIC_STRING_FROM_LITERAL(s_http_proxy_env_var_low, "http_proxy");
3434
AWS_STATIC_STRING_FROM_LITERAL(s_https_proxy_env_var, "HTTPS_PROXY");
3535
AWS_STATIC_STRING_FROM_LITERAL(s_https_proxy_env_var_low, "https_proxy");
3636

37+
#ifndef BYO_CRYPTO
3738
AWS_STATIC_STRING_FROM_LITERAL(s_proxy_no_verify_peer_env_var, "AWS_PROXY_NO_VERIFY_PEER");
39+
#endif
3840

3941
static struct aws_http_proxy_system_vtable s_default_vtable = {
4042
.setup_client_tls = &aws_channel_setup_client_tls,
@@ -1136,9 +1138,18 @@ static int s_setup_proxy_tls_env_variable(
11361138
struct aws_tls_connection_options *default_tls_connection_options,
11371139
struct aws_http_proxy_options *proxy_options,
11381140
struct aws_uri *proxy_uri) {
1141+
(void)default_tls_connection_options;
1142+
(void)proxy_uri;
11391143
if (options->proxy_ev_settings->tls_options) {
11401144
proxy_options->tls_options = options->proxy_ev_settings->tls_options;
11411145
} else {
1146+
#ifdef BYO_CRYPTO
1147+
AWS_LOGF_ERROR(
1148+
AWS_LS_HTTP_CONNECTION,
1149+
"Failed making default TLS context because of BYO_CRYPTO, set up the tls_options for proxy_env_settings to "
1150+
"make it work.");
1151+
return AWS_OP_ERR;
1152+
#else
11421153
struct aws_tls_ctx *tls_ctx = NULL;
11431154
struct aws_tls_ctx_options tls_ctx_options;
11441155
AWS_ZERO_STRUCT(tls_ctx_options);
@@ -1167,6 +1178,7 @@ static int s_setup_proxy_tls_env_variable(
11671178
return AWS_OP_ERR;
11681179
}
11691180
proxy_options->tls_options = default_tls_connection_options;
1181+
#endif
11701182
}
11711183
return AWS_OP_SUCCESS;
11721184
}

0 commit comments

Comments
 (0)