TLS transport: output some certificate information

This commit is contained in:
Přemysl Eric Janouch 2014-09-21 01:48:41 +02:00
parent d453a1226c
commit e7d8b244a9
1 changed files with 24 additions and 0 deletions

View File

@ -1011,10 +1011,34 @@ transport_tls_init (struct unit *u)
return true; return true;
} }
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 static void
transport_tls_cleanup (struct unit *u) transport_tls_cleanup (struct unit *u)
{ {
struct transport_tls_data *data = u->transport_data; 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); SSL_free (data->ssl);
free (data); free (data);
} }