aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/handshake/server_ssl.cc
diff options
context:
space:
mode:
authorGravatar Alexander Polcyn <apolcyn@google.com>2017-11-13 16:31:27 -0800
committerGravatar Alexander Polcyn <apolcyn@google.com>2017-11-13 16:31:27 -0800
commit248c4f5848c8761fc16352e1f2f1e6d047780b4e (patch)
treedb3bc383eeccf2599a2c3ddae821ad363c74515a /test/core/handshake/server_ssl.cc
parent3f6b10afba43e2855efd2fbeb3f1f4ea6c2a9657 (diff)
parente52772451a7bbf4f3f7b72cfc369781fd74a6930 (diff)
Merge remote-tracking branch 'upstream/master' into pass_args_to_tsi
Diffstat (limited to 'test/core/handshake/server_ssl.cc')
-rw-r--r--test/core/handshake/server_ssl.cc57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/core/handshake/server_ssl.cc b/test/core/handshake/server_ssl.cc
new file mode 100644
index 0000000000..736d3e578e
--- /dev/null
+++ b/test/core/handshake/server_ssl.cc
@@ -0,0 +1,57 @@
+/*
+ *
+ * Copyright 2016 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <arpa/inet.h>
+#include <openssl/err.h>
+#include <openssl/ssl.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <unistd.h>
+
+#include <grpc/grpc.h>
+#include <grpc/grpc_security.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/thd.h>
+#include "src/core/lib/iomgr/load_file.h"
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+
+#include "test/core/handshake/server_ssl_common.h"
+
+int main(int argc, char* argv[]) {
+ // Handshake succeeeds when the client supplies the standard ALPN list.
+ const char* full_alpn_list[] = {"grpc-exp", "h2"};
+ GPR_ASSERT(server_ssl_test(full_alpn_list, 2, "grpc-exp"));
+ // Handshake succeeeds when the client supplies only h2 as the ALPN list. This
+ // covers legacy gRPC clients which don't support grpc-exp.
+ const char* h2_only_alpn_list[] = {"h2"};
+ GPR_ASSERT(server_ssl_test(h2_only_alpn_list, 1, "h2"));
+ // Handshake succeeds when the client supplies superfluous ALPN entries and
+ // also when h2 precedes gprc-exp.
+ const char* extra_alpn_list[] = {"foo", "h2", "bar", "grpc-exp"};
+ GPR_ASSERT(server_ssl_test(extra_alpn_list, 4, "h2"));
+ // Handshake fails when the client uses a fake protocol as its only ALPN
+ // preference. This validates the server is correctly validating ALPN
+ // and sanity checks the server_ssl_test.
+ const char* fake_alpn_list[] = {"foo"};
+ GPR_ASSERT(!server_ssl_test(fake_alpn_list, 1, "foo"));
+ return 0;
+}