From fb73e97292f8a5b6f9a60dbcf7aeabc7759812e1 Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Wed, 2 Nov 2016 13:21:29 -0700 Subject: [PATCH] Test that version is available in the ALPN callback. HTTP/2 requires TLS 1.2 so the negotiated version should be available during the ALPN callback. Change-Id: Iea332808b531a6e5c917de5b8c8917c0aa7428a1 Reviewed-on: https://boringssl-review.googlesource.com/12060 Reviewed-by: David Benjamin Commit-Queue: David Benjamin CQ-Verified: CQ bot account: commit-bot@chromium.org --- ssl/ssl_test.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ssl/ssl_test.cc b/ssl/ssl_test.cc index eb6055034..4c658d3b8 100644 --- a/ssl/ssl_test.cc +++ b/ssl/ssl_test.cc @@ -2377,16 +2377,19 @@ static bool TestALPNCipherAvailable() { // The ALPN callback does not fail the handshake on error, so have the // callback write a boolean. - bool pending_cipher_known = false; + std::pair callback_state(version, false); SSL_CTX_set_alpn_select_cb( ctx.get(), [](SSL *ssl, const uint8_t **out, uint8_t *out_len, const uint8_t *in, unsigned in_len, void *arg) -> int { - bool *result = reinterpret_cast(arg); - *result = SSL_get_pending_cipher(ssl) != nullptr; + auto state = reinterpret_cast*>(arg); + if (SSL_get_pending_cipher(ssl) != nullptr && + SSL_version(ssl) == state->first) { + state->second = true; + } return SSL_TLSEXT_ERR_NOACK; }, - &pending_cipher_known); + &callback_state); bssl::UniquePtr client, server; if (!ConnectClientAndServer(&client, &server, ctx.get(), ctx.get(), @@ -2394,7 +2397,7 @@ static bool TestALPNCipherAvailable() { return false; } - if (!pending_cipher_known) { + if (!callback_state.second) { fprintf(stderr, "%x: The pending cipher was not known in the ALPN callback.\n", version);