aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-09-21 01:48:41 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2014-09-21 03:29:27 +0200
commite7d8b244a9fb611c1b6233e20e9186de4541feba (patch)
tree91cd8a735384d5ff7837fecff4f34d8837d203db
parentd453a1226ccef854fcec14beaba82347ad36e615 (diff)
downloadponymap-e7d8b244a9fb611c1b6233e20e9186de4541feba.tar.gz
ponymap-e7d8b244a9fb611c1b6233e20e9186de4541feba.tar.xz
ponymap-e7d8b244a9fb611c1b6233e20e9186de4541feba.zip
TLS transport: output some certificate information
-rw-r--r--ponymap.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/ponymap.c b/ponymap.c
index 2d08d98..57aa882 100644
--- a/ponymap.c
+++ b/ponymap.c
@@ -1012,9 +1012,33 @@ transport_tls_init (struct unit *u)
}
static void
+transport_tls_add_certificate_info (struct unit *u, X509 *cert)
+{
+ char *subject = X509_NAME_oneline (X509_get_subject_name (cert), NULL, 0);
+ char *issuer = X509_NAME_oneline (X509_get_issuer_name (cert), NULL, 0);
+
+ str_vector_add_owned (&u->info, xstrdup_printf ("%s: %s",
+ "certificate subject", subject));
+ str_vector_add_owned (&u->info, xstrdup_printf ("%s: %s",
+ "certificate issuer", issuer));
+
+ free (subject);
+ free (issuer);
+}
+
+static void
transport_tls_cleanup (struct unit *u)
{
struct transport_tls_data *data = u->transport_data;
+ if (u->success)
+ {
+ X509 *cert = SSL_get_peer_certificate (data->ssl);
+ if (cert)
+ {
+ transport_tls_add_certificate_info (u, cert);
+ X509_free (cert);
+ }
+ }
SSL_free (data->ssl);
free (data);
}