<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-GB link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>I’ve spent days googling this and read everything relevant in the archives.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I’m developing a Windows 7 program that connects to a financial trading exchange that expects all communication to be SSL’d. Everything I read said that stunnel is the answer because of ease of installation and use. After a day of abortive attempts to link to the exchange, I decided to create a much simpler test environment involving two Windows 7 computers next to each other here.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>One, let’s call it Riven-II (192.168.1.9), is set up with a simple Listener program that listens on port 8000. From stunnel’s viewpoint this will be a server. The second machine, Lightning (192.168.1.158), has a simple Sender program that sends a text message via port 7999 to Riven-II (192.168.1.9:8000) – this will be the Client. In the absence of stunnel, all messages sent from Lightning/Sender appears on the window of Listener. So far so good.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I’ve downloaded and installed the very latest version (4.54) of stunnel on both machines. On installation I entered the same responses to the certificate generating process.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>On the Server machine, hard wired to a Broadband Router, I configured stunnel.conf as (removing comments for simplicity)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><i>debug = 7<o:p></o:p></i></p><p class=MsoNormal><i>output = stunnel.log<o:p></o:p></i></p><p class=MsoNormal><i><o:p> </o:p></i></p><p class=MsoNormal><i>socket = l:TCP_NODELAY=1<o:p></o:p></i></p><p class=MsoNormal><i>socket = r:TCP_NODELAY=1<o:p></o:p></i></p><p class=MsoNormal><i><o:p> </o:p></i></p><p class=MsoNormal><i>cert = stunnel.pem<o:p></o:p></i></p><p class=MsoNormal><i>key = stunnel.pem<o:p></o:p></i></p><p class=MsoNormal><i><o:p> </o:p></i></p><p class=MsoNormal><i>options = NO_SSLv2<o:p></o:p></i></p><p class=MsoNormal><i><o:p> </o:p></i></p><p class=MsoNormal><i>taskbar=yes<o:p></o:p></i></p><p class=MsoNormal><i><o:p> </o:p></i></p><p class=MsoNormal><i>[Listener]<o:p></o:p></i></p><p class=MsoNormal><i>connect=8000<o:p></o:p></i></p><p class=MsoNormal><i>accept=8001<o:p></o:p></i></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>On the Client machine, connected to the router via wi-fi, we have in stunnel.conf<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><i>debug = 7<o:p></o:p></i></p><p class=MsoNormal><i>output = stunnel.log<o:p></o:p></i></p><p class=MsoNormal><i><o:p> </o:p></i></p><p class=MsoNormal><i>cert = stunnel.pem<o:p></o:p></i></p><p class=MsoNormal><i><o:p> </o:p></i></p><p class=MsoNormal><i>socket = l:TCP_NODELAY=1<o:p></o:p></i></p><p class=MsoNormal><i>socket = r:TCP_NODELAY=1<o:p></o:p></i></p><p class=MsoNormal><i><o:p> </o:p></i></p><p class=MsoNormal><i>fips=no<o:p></o:p></i></p><p class=MsoNormal><i><o:p> </o:p></i></p><p class=MsoNormal><i>options = NO_SSLv2<o:p></o:p></i></p><p class=MsoNormal><i><o:p> </o:p></i></p><p class=MsoNormal><i>delay=yes<o:p></o:p></i></p><p class=MsoNormal><i>taskbar=yes<o:p></o:p></i></p><p class=MsoNormal><i><o:p> </o:p></i></p><p class=MsoNormal><i>client=yes<o:p></o:p></i></p><p class=MsoNormal><i><o:p> </o:p></i></p><p class=MsoNormal><i>[sender]<o:p></o:p></i></p><p class=MsoNormal><i>accept  = 0.0.0.0:7999       (I’ve tried just 7999 and 192.168.1.158:7999, here. Makes no difference)<o:p></o:p></i></p><p class=MsoNormal><i>connect = 192.168.1.9:8001<o:p></o:p></i></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I’ve tried many variations with the same result, but the above is where they have ended up.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>My understanding of this is that stunnel both ends will be intercepting port 8000 on the Server and port 7999 on the Client and presenting/receiving SSL encoded messages across the wire on port 8001.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Starting stunnel in the Server  (not as a Windows service, although I did try that as well) the following log appears:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG7[3484:6184]: No limit detected for the number of clients<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG5[3484:6184]: stunnel 4.54 on x86-pc-msvc-1500 platform<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG5[3484:6184]: Compiled/running with OpenSSL 1.0.1c-fips 10 May 2012<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG5[3484:6184]: Threading:WIN32 SSL:+ENGINE+OCSP+FIPS Auth:none Sockets:SELECT+IPv6<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG5[3484:6184]: Reading configuration from file stunnel.conf<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG5[3484:6184]: FIPS mode is enabled<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG7[3484:6184]: Compression not enabled<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG7[3484:6184]: Snagged 64 random bytes from C:/.rnd<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG7[3484:6184]: Wrote 1024 new random bytes to C:/.rnd<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG7[3484:6184]: PRNG seeded successfully<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG6[3484:6184]: Initializing service [Listener]<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG7[3484:6184]: Certificate: stunnel.pem<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG7[3484:6184]: Certificate loaded<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG7[3484:6184]: Key file: stunnel.pem<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG7[3484:6184]: Private key loaded<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG7[3484:6184]: Could not load DH parameters from stunnel.pem<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG7[3484:6184]: Using hardcoded DH parameters<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG7[3484:6184]: DH initialized with 2048-bit key<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG7[3484:6184]: ECDH initialized with curve prime256v1<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG7[3484:6184]: SSL options set: 0x01000004<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG5[3484:6184]: Configuration successful<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:34:08 LOG7[3484:6184]: Service [Listener] (FD=272) bound to 0.0.0.0:8001<o:p></o:p></i></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>On the Client, the log shows:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><i>2012.11.16 22:25:53 LOG7[4184:4948]: No limit detected for the number of clients<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:25:53 LOG5[4184:4948]: stunnel 4.54 on x86-pc-msvc-1500 platform<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:25:53 LOG5[4184:4948]: Compiled/running with OpenSSL 1.0.1c-fips 10 May 2012<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:25:53 LOG5[4184:4948]: Threading:WIN32 SSL:+ENGINE+OCSP+FIPS Auth:none Sockets:SELECT+IPv6<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:25:53 LOG5[4184:4948]: Reading configuration from file stunnel.conf<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:25:53 LOG5[4184:4948]: FIPS mode is disabled<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:25:53 LOG7[4184:4948]: Compression not enabled<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:25:53 LOG7[4184:4948]: Snagged 64 random bytes from C:/.rnd<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:25:53 LOG7[4184:4948]: Wrote 1024 new random bytes to C:/.rnd<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:25:53 LOG7[4184:4948]: PRNG seeded successfully<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:25:53 LOG6[4184:4948]: Initializing service [sender]<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:25:53 LOG7[4184:4948]: Certificate: stunnel.pem<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:25:53 LOG7[4184:4948]: Certificate loaded<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:25:53 LOG7[4184:4948]: Key file: stunnel.pem<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:25:53 LOG7[4184:4948]: Private key loaded<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:25:53 LOG7[4184:4948]: SSL options set: 0x01000004<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:25:53 LOG5[4184:4948]: Configuration successful<o:p></o:p></i></p><p class=MsoNormal><i>2012.11.16 22:25:53 LOG7[4184:4948]: Service [sender] (FD=224) bound to 0.0.0.0:7999 <o:p></o:p></i></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Running the Listener on the Server and Sender on the Client adds nothing to the log, and port sniffers on both machines show traffic between 7999 and 8000 (exactly the same as when stunnel is not running). No sign of the use of port 8001.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I’d appreciate any input on this. I’m sure I must be doing something stupid, but I’ve watched hours of YouTube videos, read many hundreds of web pages, and been through the documentation quite a few times, to no avail.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I have a Java based version, running in a JVM in the same Windows machines, that talks perfectly to the exchange using some inbuilt SSL capabilities of an included library, so that should probably eliminate any hardware/router issues?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Regards, Hal<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>