Test SSL_get0_alpn_selected on both client and server.

On the server, we echo the selected ALPN back out of the same getter as
the client.

Change-Id: I11978b9cd0a3e7c611f162e9cf5054e52005a195
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/43045
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
chromium-5359
David Benjamin 5 years ago committed by CQ bot account: commit-bot@chromium.org
parent a6386ea185
commit b0e98e408c
  1. 22
      ssl/test/bssl_shim.cc

@ -524,16 +524,18 @@ static bool CheckHandshakeProperties(SSL *ssl, bool is_resume,
}
}
if (!config->is_server) {
const uint8_t *alpn_proto;
unsigned alpn_proto_len;
SSL_get0_alpn_selected(ssl, &alpn_proto, &alpn_proto_len);
if (alpn_proto_len != config->expect_alpn.size() ||
OPENSSL_memcmp(alpn_proto, config->expect_alpn.data(),
alpn_proto_len) != 0) {
fprintf(stderr, "negotiated alpn proto mismatch\n");
return false;
}
// On the server, the protocol selected in the ALPN callback must be echoed
// out of |SSL_get0_alpn_selected|. On the client, it should report what the
// test expected.
const std::string &expect_alpn =
config->is_server ? config->select_alpn : config->expect_alpn;
const uint8_t *alpn_proto;
unsigned alpn_proto_len;
SSL_get0_alpn_selected(ssl, &alpn_proto, &alpn_proto_len);
if (alpn_proto_len != expect_alpn.size() ||
OPENSSL_memcmp(alpn_proto, expect_alpn.data(), alpn_proto_len) != 0) {
fprintf(stderr, "negotiated alpn proto mismatch\n");
return false;
}
if (!config->expect_quic_transport_params.empty() && expect_handshake_done) {

Loading…
Cancel
Save