Running stunnel as a service under windows
Giuseppe J. Crisafulli <jcrisafulli[at]xram[dot]com>


Requirements:

First start by downloading the Cygwin installation package.  Follow instructions on how to proceed for installation.  During installation make sure you include the following  packages :

Download the 4 (stunnel.exe, libssl32.dll,libeay32.dll, stunnel.pem) to a directory included in your PATH environment variable (i.e. %WINDIR%system32).

If everything went OK with the Cygwin installation, you should now have Cygwin console in front of you.  To install stunnel as a service you should now type:

# cygrunsrv -I pop3s -d 'pop3s stunnel' \
                  -p /cygdrive/c/WINNT/system32/stunnel.exe \
                  -a ' -D 7 -c -d my.computer:110 -r my.pop3s.server:995' \
                  -e CYGWIN='binmode ntsec tty'

You should now be back at your Cygwin/Bash prompt, to start the service just type:

# cygrunsrv -S pop3s

To confirm that everything went OK you can do two things:

  1. Type netstat -nap tcp | grep 110  at the bash prompt.  This should "expose" one line with your local ip address colon 110 (i.e. 172.16.0.1:110) to show that there is a socket waiting for a connection on port 110.
  2. Type less /var/log/pop3s.log at the bash prompt.  This will allow you to peruse the newly created service log file.

For instructions on how to run a stunnel service without cygwin read this.

Extras

If you want to create a demon stunnel service you will need to specify the location of your certificate (stunnel.pem) , but much more important you MUST create YOUR OWN certificate.
Download the  mk_stunnel_cert.sh file containing:

#START
#!/bin/sh
# Generate a new ssl certificate 'stunnel.pem' in the current directory

openssl req -new -nodes -out required.pem -keyout private.pem
openssl rsa -in private.pem -out new.private.pem
openssl x509 -in required.pem -out ca-cert -req -signkey new.private.pem -days 365
openssl gendh > diffie_hellman
cat ca-cert >> new.private.pem
cat diffie_hellman >> new.private.pem
cp new.private.pem stunnel.pem
#FINISH

 

In the same directory, at Cygwin/Bash prompt type:

# ./mk_stunnel_cert.sh

This will create a new stunnel.pem in the current directory, you should now move it to the same directory where you dropped the stunnel.exe file.


Copyright © 2001 Giuseppe J. Crisafulli. All rights reserved.
Revised: 02/26/02
.
Hit
Counter