diff --git a/ssl/test/bssl_shim.cc b/ssl/test/bssl_shim.cc index a91524adf..76df66d35 100644 --- a/ssl/test/bssl_shim.cc +++ b/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) {