From fab3101178a6470576dabb87d7b1a482942b9faa Mon Sep 17 00:00:00 2001 From: Jean-Frederic Clere Date: Sun, 10 Apr 2016 10:19:51 +0000 Subject: [PATCH] print Server Temp Key information. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1738415 13f79535-47bb-0310-9956-ffa450edef68 --- support/ab.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/support/ab.c b/support/ab.c index 102976e345..aa75dcf48e 100644 --- a/support/ab.c +++ b/support/ab.c @@ -334,6 +334,7 @@ int is_ssl; SSL_CTX *ssl_ctx; char *ssl_cipher = NULL; char *ssl_info = NULL; +char *ssl_tmp_key = NULL; BIO *bio_out,*bio_err; #endif @@ -709,6 +710,39 @@ static void ssl_proceed_handshake(struct connection *c) SSL_CIPHER_get_name(ci), pk_bits, sk_bits); } + if (ssl_tmp_key == NULL) { + EVP_PKEY *key; + if (SSL_get_server_tmp_key(c->ssl, &key)) { + ssl_tmp_key = xmalloc(128); + switch (EVP_PKEY_id(key)) { + case EVP_PKEY_RSA: + apr_snprintf(ssl_tmp_key, 128, "RSA %d bits", + EVP_PKEY_bits(key)); + break; + case EVP_PKEY_DH: + apr_snprintf(ssl_tmp_key, 128, "DH %d bits", + EVP_PKEY_bits(key)); + break; +#ifndef OPENSSL_NO_EC + case EVP_PKEY_EC: { + const char *cname; + EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key); + int nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec)); + EC_KEY_free(ec); + cname = EC_curve_nid2nist(nid); + if (!cname) + cname = OBJ_nid2sn(nid); + + apr_snprintf(ssl_tmp_key, 128, "ECDH %s %d bits", + cname, + EVP_PKEY_bits(key)); + break; + } +#endif + } + EVP_PKEY_free(key); + } + } write_request(c); do_next = 0; break; @@ -858,6 +892,9 @@ static void output_results(int sig) if (is_ssl && ssl_info) { printf("SSL/TLS Protocol: %s\n", ssl_info); } + if (is_ssl && ssl_tmp_key) { + printf("Server Temp Key: %s\n", ssl_tmp_key); + } #endif printf("\n"); printf("Document Path: %s\n", path); -- 2.50.1