aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/end2end
diff options
context:
space:
mode:
authorGravatar Julien Boeuf <jboeuf@google.com>2015-02-02 18:36:37 -0800
committerGravatar Julien Boeuf <jboeuf@google.com>2015-02-02 18:36:37 -0800
commit026a417defcd13d0ae5e8a8ddb67c18ff02fa142 (patch)
treef281e17daf09a21193d0befb82418151e1036220 /test/core/end2end
parent40562576bc1b159c7cac873dadb89e51c95d325e (diff)
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.
Diffstat (limited to 'test/core/end2end')
-rw-r--r--test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c22
1 files changed, 21 insertions, 1 deletions
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 <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
@@ -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;
}