]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Show TLS cipher suite selected in sofia debug
authorTravis Cross <tc@traviscross.com>
Fri, 28 Feb 2014 20:28:33 +0000 (20:28 +0000)
committerTravis Cross <tc@traviscross.com>
Fri, 28 Feb 2014 20:46:34 +0000 (20:46 +0000)
This shows the cipher name, TLS version, the number of cipher bits and
algorithm bits, and a description of the cipher in Sofia's debug
logging output on level 9.

libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.c

index d6b9b324ce25a1765b4ab1f619e1c718c416042b..a63963b58e252a51005cb1e67b3d01a524f0d9f3 100644 (file)
@@ -542,11 +542,30 @@ su_inline
 int tls_post_connection_check(tport_t *self, tls_t *tls)
 {
   X509 *cert;
+  const SSL_CIPHER *cipher;
+  char cipher_description[256];
+  int cipher_bits, alg_bits;
   int extcount;
   int i, j, error;
 
   if (!tls) return -1;
 
+  if (!(cipher = SSL_get_current_cipher(tls->con))) {
+    SU_DEBUG_7(("%s(%p): %s\n", __func__, (void*)self,
+                "OpenSSL failed to return an SSL_CIPHER object to us."));
+    return SSL_ERROR_SSL;
+  }
+  SU_DEBUG_9(("%s(%p): TLS cipher chosen (name): %s\n", __func__, (void*)self,
+              SSL_CIPHER_get_name(cipher)));
+  SU_DEBUG_9(("%s(%p): TLS cipher chosen (version): %s\n", __func__, (void*)self,
+              SSL_CIPHER_get_version(cipher)));
+  cipher_bits = SSL_CIPHER_get_bits(cipher, &alg_bits);
+  SU_DEBUG_9(("%s(%p): TLS cipher chosen (bits/alg_bits): %d/%d\n", __func__, (void*)self,
+              cipher_bits, alg_bits));
+  SSL_CIPHER_description(cipher, cipher_description, sizeof(cipher_description));
+  SU_DEBUG_9(("%s(%p): TLS cipher chosen (description): %s\n", __func__, (void*)self,
+              cipher_description));
+
   cert = SSL_get_peer_certificate(tls->con);
   if (!cert) {
     SU_DEBUG_7(("%s(%p): Peer did not provide X.509 Certificate.\n",