X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Ftcpip.c;h=b9466d69379fb450eb45e2998924415aec6d3006;hp=8ffa3ab7a80724ead61dc0288f0ca363bb6faeb8;hb=896b145fa7a02199bfc3e8aa824c018b9d7cbf98;hpb=d951267dfd65b4b0741d9b9621474f2731ea3b45 diff --git a/src/tcpip.c b/src/tcpip.c index 8ffa3ab..b9466d6 100644 --- a/src/tcpip.c +++ b/src/tcpip.c @@ -1524,47 +1524,44 @@ void cs_print_session_info(COMSTACK cs) void *cs_get_ssl(COMSTACK cs) { #if HAVE_OPENSSL_SSL_H - struct tcpip_state *sp; - if (!cs || cs->type != ssl_type) - return 0; - sp = (struct tcpip_state *) cs->cprivate; - return sp->ssl; -#else - return 0; + if (cs && cs->type == ssl_type) + { + struct tcpip_state *sp = (struct tcpip_state *) cs->cprivate; + return sp->ssl; + } #endif + return 0; } int cs_set_ssl_ctx(COMSTACK cs, void *ctx) { #if ENABLE_SSL - struct tcpip_state *sp; - if (!cs || cs->type != ssl_type) - return 0; - sp = (struct tcpip_state *) cs->cprivate; + if (cs && cs->type == ssl_type) + { #if HAVE_OPENSSL_SSL_H - if (sp->ctx_alloc) - return 0; - sp->ctx = (SSL_CTX *) ctx; + struct tcpip_state *sp = (struct tcpip_state *) cs->cprivate; + if (sp->ctx_alloc) + return 0; + sp->ctx = (SSL_CTX *) ctx; #endif - return 1; -#else - return 0; + return 1; + } #endif + return 0; } int cs_set_ssl_certificate_file(COMSTACK cs, const char *fname) { #if ENABLE_SSL - struct tcpip_state *sp; - if (!cs || cs->type != ssl_type) - return 0; - sp = (struct tcpip_state *) cs->cprivate; - strncpy(sp->cert_fname, fname, sizeof(sp->cert_fname)-1); - sp->cert_fname[sizeof(sp->cert_fname)-1] = '\0'; - return 1; -#else - return 0; + if (cs && cs->type == ssl_type) + { + struct tcpip_state *sp = (struct tcpip_state *) cs->cprivate; + strncpy(sp->cert_fname, fname, sizeof(sp->cert_fname)-1); + sp->cert_fname[sizeof(sp->cert_fname)-1] = '\0'; + return 1; + } #endif + return 0; } int cs_get_peer_certificate_x509(COMSTACK cs, char **buf, int *len)