+#if HAVE_OPENSSL_SSL_H
+ if ((ssl = (SSL *) cs_get_ssl(conn)))
+ {
+ X509 *server_cert = SSL_get_peer_certificate (ssl);
+ char *str;
+ if (server_cert)
+ {
+ printf ("Server certificate:\n");
+
+ str = X509_NAME_oneline (X509_get_subject_name (server_cert),0,0);
+ if (str)
+ {
+ printf ("\t subject: %s\n", str);
+ free (str);
+ }
+ str = X509_NAME_oneline (X509_get_issuer_name (server_cert),0,0);
+ if (str)
+ {
+ printf ("\t issuer: %s\n", str);
+ free (str);
+ }
+ X509_free (server_cert);
+ }
+ }
+#endif