From: Adam Dickmeiss Date: Wed, 28 Apr 2004 13:25:57 +0000 (+0000) Subject: More SSL details for yaz-client X-Git-Tag: YAZ.2.0.20~27 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=a159d35487ce391123e8e82274fd2ee95055c3a6;p=yaz-moved-to-github.git More SSL details for yaz-client --- diff --git a/client/client.c b/client/client.c index cacc274..fd2d592 100644 --- a/client/client.c +++ b/client/client.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2004, Index Data * See the file LICENSE for details. * - * $Id: client.c,v 1.239 2004-04-28 12:10:51 adam Exp $ + * $Id: client.c,v 1.240 2004-04-28 13:25:57 adam Exp $ */ #include @@ -17,6 +17,7 @@ #endif #if HAVE_OPENSSL_SSL_H +#include #include #include #include @@ -602,22 +603,22 @@ int session_connect(const char *arg) { 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); - } + 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); } }