diff options
author | David Benjamin <davidben@chromium.org> | 2014-07-03 02:37:33 +0400 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2014-07-03 02:52:59 +0400 |
commit | 197b3abaa8e1a1954a5bf16edacf49305b1bada1 (patch) | |
tree | 83c6dc98c74f88213f3ef3abbbc8eef6ff7b4842 | |
parent | 025b3d3459260670a883169cf0940e94cbd79b94 (diff) |
Add a test that server_name extensions are parsed correctly.
Change-Id: Id4025835df49eb498df9a48fc81061541778569b
Reviewed-on: https://boringssl-review.googlesource.com/1092
Reviewed-by: Adam Langley <agl@google.com>
-rw-r--r-- | ssl/test/bssl_shim.cc | 18 | ||||
-rw-r--r-- | ssl/test/runner/runner.go | 8 |
2 files changed, 26 insertions, 0 deletions
diff --git a/ssl/test/bssl_shim.cc b/ssl/test/bssl_shim.cc index e8cca129..1dde8192 100644 --- a/ssl/test/bssl_shim.cc +++ b/ssl/test/bssl_shim.cc @@ -74,6 +74,7 @@ err: int main(int argc, char **argv) { int i, is_server, ret; + const char *expected_server_name = NULL; if (argc < 2) { fprintf(stderr, "Usage: %s (client|server) [flags...]\n", argv[0]); @@ -120,6 +121,13 @@ int main(int argc, char **argv) { BIO_print_errors_fp(stdout); return 1; } + } else if (strcmp(argv[i], "-expect-server-name") == 0) { + i++; + if (i >= argc) { + fprintf(stderr, "Missing parameter\n"); + return 1; + } + expected_server_name = argv[i]; } else { fprintf(stderr, "Unknown argument: %s\n", argv[i]); return 1; @@ -137,6 +145,16 @@ int main(int argc, char **argv) { return 2; } + if (expected_server_name) { + const char *server_name = + SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name); + if (strcmp(server_name, expected_server_name) != 0) { + fprintf(stderr, "servername mismatch (got %s; want %s)\n", + server_name, expected_server_name); + return 2; + } + } + for (;;) { uint8_t buf[512]; int n = SSL_read(ssl, buf, sizeof(buf)); diff --git a/ssl/test/runner/runner.go b/ssl/test/runner/runner.go index 2cda6605..f253f897 100644 --- a/ssl/test/runner/runner.go +++ b/ssl/test/runner/runner.go @@ -135,6 +135,14 @@ var testCases = []testCase{ }, flags: []string{"-fallback-scsv"}, }, + { + testType: serverTest, + name: "ServerNameExtension", + config: Config{ + ServerName: "example.com", + }, + flags: []string{"-expect-server-name", "example.com"}, + }, } func doExchange(tlsConn *Conn, messageLen int) error { |