From 026a417defcd13d0ae5e8a8ddb67c18ff02fa142 Mon Sep 17 00:00:00 2001 From: Julien Boeuf Date: Mon, 2 Feb 2015 18:36:37 -0800 Subject: Adding support for loading the SSL roots from an environment variable. - Had to add support for files and environment variables as well. - I can't compile on windows so I'm sure there will be some issues. - Tested end-to-end with the simple ssl fullstack test. --- .../end2end/fixtures/chttp2_simple_ssl_fullstack.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'test/core/end2end/fixtures') diff --git a/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c index a70819e47e..876d35a74b 100644 --- a/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c +++ b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c @@ -39,6 +39,9 @@ #include "src/core/channel/channel_args.h" #include "src/core/security/credentials.h" #include "src/core/security/security_context.h" +#include "src/core/support/env.h" +#include "src/core/support/file.h" +#include "src/core/support/string.h" #include #include #include @@ -99,7 +102,7 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { static void chttp2_init_client_simple_ssl_secure_fullstack( grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { grpc_credentials *ssl_creds = - grpc_ssl_credentials_create(test_root_cert, NULL); + grpc_ssl_credentials_create(NULL, NULL); grpc_arg ssl_name_override = {GRPC_ARG_STRING, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, {"foo.test.google.com"}}; @@ -129,8 +132,21 @@ static grpc_end2end_test_config configs[] = { int main(int argc, char **argv) { size_t i; + FILE *roots_file; + size_t roots_size = strlen(test_root_cert); + char *roots_filename; + grpc_test_init(argc, argv); + /* Set the SSL roots env var. */ + roots_filename = gpr_strdup("chttp2_simple_ssl_fullstack_test_XXXXXX"); + GPR_ASSERT(roots_filename != NULL); + roots_file = gpr_tmpfile(roots_filename); + GPR_ASSERT(roots_file != NULL); + GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); + fclose(roots_file); + gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); + grpc_init(); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { @@ -139,5 +155,9 @@ int main(int argc, char **argv) { grpc_shutdown(); + /* Cleanup. */ + remove(roots_filename); + gpr_free(roots_filename); + return 0; } -- cgit v1.2.3