aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/util
diff options
context:
space:
mode:
authorGravatar chenw <chenw@google.com>2014-12-19 17:12:36 -0800
committerGravatar Jan Tattermusch <jtattermusch@google.com>2014-12-29 17:06:52 -0800
commit97fd9e56d2940cde9983b978a274cce62e02be3e (patch)
tree4c3907dd3ebcbd751a7b311e7df42028704a523d /test/cpp/util
parent3bf466fb6c8cbbd4334d70be9c251feb71a7c78a (diff)
Add SSL root for production GFE.
Change on 2014/12/19 by chenw <chenw@google.com> ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=82554526
Diffstat (limited to 'test/cpp/util')
-rw-r--r--test/cpp/util/create_test_channel.cc22
-rw-r--r--test/cpp/util/create_test_channel.h4
2 files changed, 17 insertions, 9 deletions
diff --git a/test/cpp/util/create_test_channel.cc b/test/cpp/util/create_test_channel.cc
index 14b566fb12..f0d35d98c2 100644
--- a/test/cpp/util/create_test_channel.cc
+++ b/test/cpp/util/create_test_channel.cc
@@ -44,19 +44,23 @@ namespace grpc {
// create channel. Otherwise, connect to server and override hostname if
// override_hostname is provided.
// When ssl is not enabled, override_hostname is ignored.
+// Set use_prod_root to true to use the SSL root for production GFE. Otherwise,
+// root for test SSL cert will be used.
// Use examples:
-// CreateTestChannel("1.1.1.1:12345", "override.hostname.com", true);
-// CreateTestChannel("test.google.com:443", "", true);
-// CreateTestChannel("", "test.google.com:443", true); // same as above
+// CreateTestChannel("1.1.1.1:12345", "override.hostname.com", true, false);
+// CreateTestChannel("test.google.com:443", "", true, true);
+// CreateTestChannel("", "test.google.com:443", true, true); // same as above
std::shared_ptr<ChannelInterface> CreateTestChannel(
const grpc::string& server, const grpc::string& override_hostname,
- bool enable_ssl) {
+ bool enable_ssl, bool use_prod_roots) {
ChannelArguments channel_args;
if (enable_ssl) {
- SslCredentialsOptions ssl_opts = {
- {reinterpret_cast<const char*>(test_ca_cert), test_ca_cert_size},
- "",
- ""};
+ const char* roots_certs =
+ use_prod_roots ? reinterpret_cast<const char*>(prod_roots_certs)
+ : reinterpret_cast<const char*>(test_root_cert);
+ unsigned int roots_certs_size =
+ use_prod_roots ? prod_roots_certs_size : test_root_cert_size;
+ SslCredentialsOptions ssl_opts = {{roots_certs, roots_certs_size}, "", ""};
std::unique_ptr<Credentials> creds =
CredentialsFactory::SslCredentials(ssl_opts);
@@ -75,7 +79,7 @@ std::shared_ptr<ChannelInterface> CreateTestChannel(
// Shortcut for end2end and interop tests.
std::shared_ptr<ChannelInterface> CreateTestChannel(const grpc::string& server,
bool enable_ssl) {
- return CreateTestChannel(server, "foo.test.google.com", enable_ssl);
+ return CreateTestChannel(server, "foo.test.google.com", enable_ssl, false);
}
} // namespace grpc
diff --git a/test/cpp/util/create_test_channel.h b/test/cpp/util/create_test_channel.h
index 10e301cb21..17b519ecb0 100644
--- a/test/cpp/util/create_test_channel.h
+++ b/test/cpp/util/create_test_channel.h
@@ -48,6 +48,10 @@ std::shared_ptr<ChannelInterface> CreateTestChannel(
std::shared_ptr<ChannelInterface> CreateTestChannel(const grpc::string& server,
bool enable_ssl);
+std::shared_ptr<ChannelInterface> CreateTestChannel(
+ const grpc::string& server, const grpc::string& override_hostname,
+ bool enable_ssl, bool use_prod_roots);
+
} // namespace grpc
#endif // __GRPCPP_TEST_UTIL_CREATE_TEST_CHANNEL_H_