X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Ftcpip.c;h=5f46f3e4f42eb7b2a8cd79cd6b36fbc7bd3590eb;hb=e72e394106dd25d6a8a8c7c2fa677f40ef5e7eb6;hp=92b3100ef07797668a7cdef014d80a897e8ea406;hpb=a159d35487ce391123e8e82274fd2ee95055c3a6;p=yaz-moved-to-github.git diff --git a/src/tcpip.c b/src/tcpip.c index 92b3100..5f46f3e 100644 --- a/src/tcpip.c +++ b/src/tcpip.c @@ -1,8 +1,8 @@ /* - * Copyright (c) 1995-2003, Index Data + * Copyright (c) 1995-2004, Index Data * See the file LICENSE for details. * - * $Id: tcpip.c,v 1.2 2004-04-28 12:10:53 adam Exp $ + * $Id: tcpip.c,v 1.3 2004-04-28 22:44:59 adam Exp $ */ #include @@ -1108,9 +1108,38 @@ void *cs_get_ssl(COMSTACK cs) state = (struct tcpip_state *) cs->cprivate; return state->ssl; } + +int cs_get_peer_certificate_x509(COMSTACK cs, char **buf, int *len) +{ + SSL *ssl = cs_get_ssl(cs); + if (ssl) + { + X509 *server_cert = SSL_get_peer_certificate (ssl); + if (server_cert) + { + BIO *bio = BIO_new(BIO_s_mem()); + char *pem_buf; + /* get PEM buffer in memory */ + PEM_write_bio_X509(bio, server_cert); + *len = BIO_get_mem_data(bio, &pem_buf); + *buf = xmalloc(*len); + memcpy(*buf, pem_buf, *len); + BIO_free(bio); + return 1; + } + } + return 0; +} #else void *cs_get_ssl(COMSTACK cs) { return 0; } + +int cs_get_peer_certificate_x509(COMSTACK cs, char **buf, int *len) +{ + return 0; +} + #endif +