-#if HAVE_OPENSSL_SSL_H
- if ((ssl = (SSL *) cs_get_ssl(conn)))
- {
- X509 *server_cert = SSL_get_peer_certificate (ssl);
-
- if (server_cert)
- {
- char *pem_buf;
- int pem_len;
- BIO *bio = BIO_new(BIO_s_mem());
-
- /* get PEM buffer in memory */
- PEM_write_bio_X509(bio, server_cert);
- pem_len = BIO_get_mem_data(bio, &pem_buf);
- fwrite(pem_buf, pem_len, 1, stdout);
-
- /* print all info on screen .. */
- X509_print_fp(stdout, server_cert);
- BIO_free(bio);
-
- X509_free (server_cert);
- }
- }
-#endif