X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fcrypto.c;h=d55d8791aa9283202c842ba08b6bec61fa20f8ae;hb=cafc916839c04d648e85a8efd822c9bb95832cdf;hp=98f1450795b351fb7af7a0f05d5df8ab79dcfe2d;hpb=18da598d894ac1698038a278d919fa4301dd8d47;p=citadel.git diff --git a/webcit/crypto.c b/webcit/crypto.c index 98f145079..d55d8791a 100644 --- a/webcit/crypto.c +++ b/webcit/crypto.c @@ -363,6 +363,8 @@ int starttls(int sock) { */ void endtls(void) { + if (THREADSSL == NULL) return; + lprintf(5, "Ending SSL/TLS\n"); SSL_shutdown(THREADSSL); SSL_free(THREADSSL); @@ -390,16 +392,18 @@ void client_write_ssl(char *buf, int nbytes) int nremain; char junk[1]; + if (THREADSSL == NULL) return; + nremain = nbytes; while (nremain > 0) { if (SSL_want_write(THREADSSL)) { if ((SSL_read(THREADSSL, junk, 0)) < 1) { - lprintf(9, "SSL_read in client_write: %s\n", ERR_reason_error_string(ERR_get_error())); + lprintf(9, "SSL_read in client_write: %s\n", + ERR_reason_error_string(ERR_get_error())); } } - retval = - SSL_write(THREADSSL, &buf[nbytes - nremain], nremain); + retval = SSL_write(THREADSSL, &buf[nbytes - nremain], nremain); if (retval < 1) { long errval; @@ -410,8 +414,9 @@ void client_write_ssl(char *buf, int nbytes) continue; } lprintf(9, "SSL_write got error %ld, ret %d\n", errval, retval); - if (retval == -1) + if (retval == -1) { lprintf(9, "errno is %d\n", errno); + } endtls(); return; } @@ -434,6 +439,8 @@ int client_read_ssl(char *buf, int bytes, int timeout) int len, rlen; char junk[1]; + if (THREADSSL == NULL) return(0); + len = 0; while (len < bytes) { #if 0