Hi,
I am using stunnel 4.15 on Windows XP SP1 with Mozilla Thunderbird as the e-mail client. I do not have openSSL installed locally. I do have the libssl32.dll and libeay32.dll in the same directory as stunnel.exe (C:\Program Files\stunnel). I am running stunnel as a service.
Stunnel crashes when I use it to send e-mail (SMTP via TLS) via gmail.
According to the e-mail client configuration page on the gmail website http://mail.google.com/support/bin/answer.py?answer=13287&topic=1555
I tried to use SMTP over TLS to connect to smtp.gmail.com:587
My gmail-smtps block in stunnel.conf was
; SMTP service, listens on localhost:250 [gmail-smtps] protocol=smtp accept=localhost:250 connect=smtp.gmail.com:587
On trying to send an e-mail message via the above configuration stunnel crashed. The log file is as follows
2006.06.14 03:17:15 LOG5[3956:3512]: stunnel 4.15 on x86-pc-mingw32-gnu with OpenSSL 0.9.7i 14 Oct 2005 2006.06.14 03:17:15 LOG5[3956:3512]: Threading:WIN32 SSL:ENGINE Sockets:SELECT,IPv6 2006.06.14 03:17:15 LOG5[3956:3600]: No limit detected for the number of clients 2006.06.14 03:17:15 LOG7[3956:3600]: FD 172 in non-blocking mode 2006.06.14 03:17:15 LOG7[3956:3600]: SO_REUSEADDR option set on accept socket 2006.06.14 03:17:15 LOG7[3956:3600]: gmail-pop3s bound to 127.0.0.1:1100 2006.06.14 03:17:15 LOG7[3956:3600]: FD 180 in non-blocking mode 2006.06.14 03:17:15 LOG7[3956:3600]: SO_REUSEADDR option set on accept socket 2006.06.14 03:17:15 LOG7[3956:3600]: gmail-smtps bound to 127.0.0.1:250
....# info about other mail connections
2006.06.14 03:17:26 LOG7[3956:3600]: gmail-smtps accepted FD=236 from 127.0.0.1:3665 2006.06.14 03:17:26 LOG7[3956:3600]: Creating a new thread 2006.06.14 03:17:26 LOG7[3956:3600]: New thread created 2006.06.14 03:17:26 LOG7[3956:2812]: gmail-smtps started 2006.06.14 03:17:26 LOG7[3956:2812]: FD 236 in non-blocking mode 2006.06.14 03:17:26 LOG7[3956:2812]: TCP_NODELAY option set on local socket 2006.06.14 03:17:26 LOG5[3956:2812]: gmail-smtps connected from 127.0.0.1:3665 2006.06.14 03:17:26 LOG7[3956:2812]: FD 268 in non-blocking mode 2006.06.14 03:17:26 LOG7[3956:2812]: gmail-smtps connecting 64.233.167.111:587 2006.06.14 03:17:26 LOG7[3956:2812]: connect_wait: waiting 10 seconds 2006.06.14 03:17:26 LOG7[3956:2812]: connect_wait: connected 2006.06.14 03:17:26 LOG7[3956:2812]: Remote FD=268 initialized 2006.06.14 03:17:26 LOG7[3956:2812]: TCP_NODELAY option set on remote socket 2006.06.14 03:17:26 LOG5[3956:2812]: Negotiations for smtp (client side) started 2006.06.14 03:17:26 LOG7[3956:2812]: <- 220 mx.gmail.com ESMTP w66sm450524pyw 2006.06.14 03:17:26 LOG7[3956:2812]: -> 220 mx.gmail.com ESMTP w66sm450524pyw
<logfile ends>
What mistake am I making?
Fortunately it seems that gmail supports SMTP over SSL too (smtp.gmail.com:465) and I am using that. However I am also facing this problem with another account which unfortunately allows SMTP only over TLS.
Thanks, Shatadal.
--- avast! Antivirus: Outbound message clean. Virus Database (VPS): 0624-1, 06/13/2006 Tested on: 6/14/2006 6:22:04 AM avast! - copyright (c) 2000-2006 ALWIL Software. http://www.avast.com
_________________________________________________________________ Is your PC infected? Get a FREE online computer virus scan from McAfee® Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
Wed Jun 14 13:32:39 2006 Shatadal Ghosh wrote,
Stunnel crashes when I use it to send e-mail (SMTP via TLS) via gmail.
According to the e-mail client configuration page on the gmail website http://mail.google.com/support/bin/answer.py?answer=13287&topic=1555
I tried to use SMTP over TLS to connect to smtp.gmail.com:587
....
2006.06.14 03:17:26 LOG5[3956:2812]: Negotiations for smtp (client side) started 2006.06.14 03:17:26 LOG7[3956:2812]: <- 220 mx.gmail.com ESMTP w66sm450524pyw 2006.06.14 03:17:26 LOG7[3956:2812]: -> 220 mx.gmail.com ESMTP w66sm450524pyw
<logfile ends>
I have confused with the same problem on my FreeBSD executable. gdb says,
.... 2006.08.24 00:18:20 LOG7[65395:134637568]: <- 220 dion.ne.jp ESMTP 2006.08.24 00:18:20 LOG7[65395:134637568]: -> 220 dion.ne.jp ESMTP
Program received signal SIGBUS, Bus error. fdputline (c=0x8076000, fd=7, line=0x8056237 "EHLO localhost") at network.c:565 565 safeconcat(line, crlf); (gdb) until
Program terminated with signal SIGBUS, Bus error. The program no longer exists. ----
safeconcat() may be safe, but argument pointers are used little bit dangerous manner.
I had made a work around to address to it, and looks work fine here. Similer codes could be in sources.
diff -ru stunnel-4.15.orig/src/network.c stunnel-4.15/src/network.c --- stunnel-4.15.orig/src/network.c Wed Mar 1 23:41:08 2006 +++ stunnel-4.15/src/network.c Thu Aug 24 00:24:24 2006 @@ -555,6 +555,7 @@
void fdputline(CLI *c, int fd, char *line) { char logline[STRLEN]; + char xline[STRLEN]; const char crlf[]="\r\n";
if(strlen(line)+2>=STRLEN) { /* 2 for crlf */ @@ -562,8 +563,9 @@ longjmp(c->err, 1); } safecopy(logline, line); /* the line without crlf */ - safeconcat(line, crlf); - write_blocking(c, fd, line, strlen(line)); + safecopy(xline, line); /* the line without crlf */ + safeconcat(xline, crlf); + write_blocking(c, fd, xline, strlen(xline)); safestring(logline); s_log(LOG_DEBUG, " -> %s", logline); }