Stunnel.org  
   
Home
About
News
Faq
Examples
Download
Patches
Support
Related
<FAQ> <4.x Man Page> <3.x Man Page> <Installing> <Running> <Arguments> <Other Applications> <Certificates> <Miscellany> <Terminology> <Troubleshooting>
Stunnel FAQ: Troubleshooting Chapter Contents:


Troubleshooting

This section gives you very basic information on how to troubleshoot Stunnel.


Upgrading from 3.x to 4.x

  • I want to upgrade to 4.x, but I can't get a working config file!

    Try using either the stunnel3_convert or stunnel3_wrapper programs in the contrib directory. The former takes a Stunnel-3.x command line and converts it to a valid 4.x config file on stdout. The later creates a temporary config file and actually runs Stunnel-4.x with it. Example:

        $ stunnel3_convert  -c -d 143 -r 993 -n imap
        client = yes
    
        [imap]
        accept = 143
        connect = 993
        

    There's also a good article available at freebsddiary.org that describes 3.x => 4.x conversion.


Common Compilation Problems

  • I'm having trouble compiling Stunnel on my Immunix box or with StackGuard/FormatGuard

    Stunnel has many #ifdef statements to make it portable to many systems, including some involving the *printf() commands. This makes FormatGuard very unhappy. Currently your only option is to not compile with FormatGuard. Stunnel does it's string manipulation and syslogging with safe functions to protect against overflows and format string bugs. You're welcome to do a source code audit, of course, as others, myself included, have.

  • "Couldn't find your SSL library installation dir" when running configure

    Solution: The first posibility is that you haven't installed an SSL library, either OpenSSL or SSLeay. In that case you should download and compile one of them. OpenSSL can be found at www.openssl.org.

    The other possibility is that you installed your SSL library in a non-standard place. Use the --with-ssl directive when running configure to tell it where this directory is.

    Note this is the directory in which you have a certs subdirectory, and the SSL libraries. If your certs directory is not inside your SSL library directory, then you must make a link to the certs directory inside your SSL directory.


  • Too few arguments to function `PEM_read_bio_DHparams'

    "I get the following error when I try to compile Stunnel:"
        ssl.c: In function `context_init':
        ssl.c:205: too few arguments to function
                   `PEM_read_bio_DHparams'
        

    Solution: You are probably using one of the older versions of Stunnel (3.4a and earlier) You can either upgrade to a newer version which has better OpenSSL support, or do the following:

    OpenSSL 0.9.4 changed the parameters sent to the PEM_read_bio_DHparams function. You can apply a patch contributed by Mark D. Baushke:

    To use it, save the patch into a file called 'stunnel-openssl.patch' in the directory in which you unpacked Stunnel. Then run the command
    patch < stunnel-openssl.patch
    and recompile Stunnel.

    If you do not have (or feel comfortable with) patch, you could simply change line 205 of ssl.c from

       if(!(dh=PEM_read_bio_DHparams(bio, NULL, NULL))) {
    	
    to
       if(!(dh=PEM_read_bio_DHparams(bio, NULL, NULL, NULL))) {
    	
    The patch above is much more portable however.


  • Errors about 'ssl.h: No such file or directory'

    When I try to compile I get errors like the following:
    	gcc -g -O2 -Wall -I/usr/include
    	    -Dlibdir=\"/usr/local/lib\" -c  ssl.c
    	ssl.c:83: lhash.h: No such file or directory
    	ssl.c:84: ssl.h: No such file or directory
    	ssl.c:85: err.h: No such file or directory
    	

    Solution: The distribution currently has a bug where it may not find your SSL directories. This will be fixed in an upcoming version. If you have SSL configured in a non-standard place, use this configure script instead of the one that comes with Stunnel. It adds a flag '--with-ssl=PATH' to specify the actual locations of your ssl installation.


  • configure isn't finding my TCP Wrapper installation

    Solution: You probably have it in a non-standard place, ie somewhere that gcc can't find it on it's own.

    Let's say you had your tcp wrappers installed in /opt/tcpd_7.6. To help gcc find your include files and libraries, you'd want to set three environment variables as follows:

     
         CFLAGS="$CFLAGS     -I/opt/tcpd_7.6/include"
         CPPFLAGS="$CPPFLAGS -I/opt/tcpd_7.6/include"
         LDFLAGS="$LDFLAGS   -L/opt/tcpd_7.6/lib"
         export CFLAGS CPPFLAGS LDFLAGS
         
    And then re-run configure. This is the generic way to have configure find specific libraries, and is not specific to Stunnel itself.


  • The files I'm downloading are corrupted / wrong size!

    Your browser (bet you're using netscape) is being helpful and gunzipping it for you, but is leaving the .gz extension, and you probably have the uncompressed tar archive with a misleading name. Try untaring it directly.


What to do when Stunnel fails

Firstly, the most important things to try when you're having trouble running Stunnel is to:
  • run with full debug mode -D 7
  • if running the daemon, run it in the foreground -f
Doing this gives you the best chance of catching the errors in the log on the screen.


I don't have the openssl binary / Can't make stunnel.pem!

If you don't have the openssl program (for example you're using the precompiled version of Stunnel on a Windows machine) then you need to generate an stunnel.pem file in some other manner. You can find a spare unix workstation that does have openssl installed, for example.

If you still can't get your hands on a machine with openssl installed, you can generate a certificate using the stunnel.org server by going to http://www.stunnel.org/pem/.


Problems running Stunnel

  • When I run Stunnel 4.x, it just sits there, it doesn't listen for requests!

    You are probably missing the [service] definition in your config. For example

    	pid = /stunnel.pid
    	setuid = nobody
    	setgid = nobody
    	debug  = local6.err
    	foreground = no
    	client = yes
    
    	[mysyslog]
    		accept   = localhost:syslog
    		connect  = logging:syslogs
    	

    Without that [mysyslog] line, Stunnel 4.x assumes you want to operate in inetd-style mode. (See Running Stunnel for more info.)

  • I get an error about opening /dev/cryptonet

    Per Christian Seberino, remove the hwcrypto RPM and all should fix itself.

  • I get the error 'Wrong permissions on stunnel.pem'

    I get the error

    stunnel[PID]: Wrong permissions on /path/to/stunnel.pem

    on my Stunnel server or on Stunnel client using client-side certificates. What's wrong?

    Answer: The stunnel.pem file contains your key (private data) and certificate (public data). In order for Stunnel to start automatically without requiring a password, the key is created without a password. This means that anyone who can read this file can compromise your SSL security. This file must be readable only by root, or the user who runs Stunnel.

    Use the chmod command to fix permissions on this file, ala

    chmod 600 /path/to/stunnel.pem


  • SSL_accept: error:00000000::lib(0) :func(0) :reason(0)

    I get the error

    SSL_accept: error:00000000::lib(0) :func(0) :reason(0)

    What does it mean?

    Answer: That error means that your client has closed the connection before SSL was negotiated. That probably means that you're trying to connect to your Stunnel daemon with a non-SSL client. Make sure you are using SSL on your client.


  • FTP over Stunnel won't work

    I just can't get ftp to work over Stunnel no matter how hard I try.

    Answer: Stunnel cannot be used for the FTP daemon because of the nature of the FTP protocol which utilizes multiple ports for data transfers. There are SSL aware FTP servers available.

    Alternitively you could use a different protocol. All versions of SSH include a program called scp which works like rcp. Recent versions of OpenSSH include a program called sftp which has an ftp-like feel.


  • Stunnel isn't working with Windows with strong crypto.

    Try installing the High Encryption Pack and all other service packs -- this may be the problem.


  • Stunnel isn't working with Windows 2000 (Outlook Express).

    The error looks like the following:
    SSL_accept:error:140760F8:SSL
        routines:SSL23_GET_CLIENT_HELLO:unknown protocol
    
    SSL_accept:error:1409B0AB:SSL
        routines:SSL3_SEND_SERVER_KEY_EXCHANGE:missing
        tmp rsa key
    Solution: One day after the official release of Windows 2000 a number of 'Critical Updates' were released. At least one of them fixes the problem, probably the "128bit encryption pack update".

    It is not determined if this applies to merely Outlook, or Windows 2000 in general, however it's a good idea to update your machine.


  • How do I configure Outlook to use SSL?

    To use POP with SSL in Outlook (tested with 2000, 98, and Outlook Express, should work with other versions), simply select the checkbox under the 'Incoming mail (POP3)' section that says 'This server requires a secure connection (SSL). This is all located on the advanced tab in the account properties. Make sure that the port it changes to when you check the box is correct (should be 995 by default) and you should be golden.

    Submitted by Green Onyx <lists@greenonyx.com>


  • I can't type anything when running Stunnel in client mode on Windows.

    Solution: The version of OpenSSL with which the pre-compiled Stunnel binary was made did not support reading in from standard in, thus if you want to use Stunnel in client mode in a way such as

    stunnel -c -r www:443
    then it will not work.

    OpenSSL 0.9.5 and newer claim it supports this now. If anyone can try and report back that would be wonderful.


  • Stunnel doesn't seem to be reusing session IDs in client mode.

    Solution: Stunnel has a bug in versions up to 3.8. It didn't correctly attempt to set the SessionID, and thus never used it when it should have been available. Try using this patch) to ssl.c. This patch was integrated in 3.8p1 and later.


  • Stunnel 3.8 or earlier fails with a "PRNG not seeded" error message.

    Solution Download Stunnel 3.8p1 or later, or apply the patch for this problem available from the stunnel.org patch library

    The problem stems from the fact that as of OpenSSL 0.9.5, the underlying SSL libraries require that the cryptographic algorithms have their random number generator seeded with random information. See http://www.openssl.org/support/faq.html#USER1 for the explanation.

    All versions from 3.8p1 on have this bug fixed. Prior to that it only affected operating systems without a /dev/urandom device.

  • Stunnel 3.8 or greater fails with a "PRNG not seeded" error message.

    You are likely not on a system that has /dev/urandom, and OpenSSL is not able to gather enough entropy to create strong SSL sessions. Option include, in rough order of preference:
    • Use PRNGd (Portable Random Number Generator Daemon) available here. This is an EGD compatible random number generator. It gathers entropy from system commands and feeds them to the OpenSSL RNG, and thus will never block waiting for more random data. Point to your PRNGd socket with the '-E /path/to/sock' argument to Stunnel.
    • Use EGD (Entropy Gathering Daemon) available here. EGD was the first widely used RNG that got it's entropy from system commands. Unfortunately EGD can block (ie hang) until it gathers enough entropy. (For this reason PRNGd is prefered over EGD.) Point to your EGD socket with the '-E /path/to/sock' argument to Stunnel.
    • If you are running Solaris, snag the SUNWski patch, which will create /dev/random for you. Simply 'ln -s random /dev/urandom' and OpenSSL (and thus Stunnel) will find entropy for you automatically.

      This patch has been reported to be available as part of the following patches, YMMV: 105710-01, 106754-01, 106755-01, 106756-01.

      On Solaris 8 you could install patch 112438 to get /dev/random and /dev/urandom devices.

    • In the worst case you can create a file or files with random data (for example copy sections of your running kernel to a file) and use them to seed the data. See the Stunnel manual page 'RANDOMNESS' section for the full list of which files are searched and in which order. It is important to remember that these random datafiles may be overwritten unless the -W flag is used!


  • Why won't transparent mode work?

    See the transparent mode issues page.


  • Secure Password Authentication error with Outlook and POP

    When I try to use pop with Outlook I get the following error:

    Unable to logon to the server using Secure Password
    Authentication.  Account: 'example.net', Server:
    'mail.example.net', Protocol: POP3,
    Server Response: '.', Port: 995,
    Secure(SSL): Yes, Error Number: 0x800CCC18
    	

    You told Outlook to use Secure Password Authentication, but your POP server doesn't support it. Since you're using Stunnel, your password is not ever in the clear anyway, so you can just turn off Secure Password Authentication.


    Help, I've got zombies!

    If you find you are getting zombie processes (those that have been created by Stunnel and end up in a <defunct> state that never get cleaned up) then you should upgrade to Stunnel 3.14 or later. Zombie problems seem to have been solidly fixed by then.

    Note that many SSL clients will keep open a connection, and thus a process that is still lingering may be there simply because it's still in use. POP and IMAP commonly stick around after mail has been gathered, even though you don't notice activity.


    Help! I'm running on Linux with threads, but Stunnel keeps forking off processes anyway!

    Linux threads have entries in the process table. A threaded Stunnel daemon will have n+1 entries in /proc, where n is the number of current threads. It's not an error.

    If you have arguments against this way of implementing threads, talk to Linus. Linux threads are damned fast as they are, so you're not likely to convince him to change things.


    I'm trying to use Stunnel as a pipe, but it doesn't seem to work!

    You're probably using an older version of Stunnel, before 3.16. Try an upgrade and you'll probably be much happier.

    If you want to stick with one of the older versions, there are a few other options. If you're just trying to snag a https:// web page, for example, all you really need to do is use the openssl program itself, such as:

    $ openssl s_client -connect www:443 -quiet 2>/dev/null <<EOM
    GET /blah.html HTTP/1.0
    
    EOM
    Which should do the trick. Alternatively, you could apply the stdout patch by Markus Foerster in the patches directory.


    I'm having trouble with MySQL and Stunnel

    (Submitted by Leon Harris ) Problem: "After I start the tunnel on the server, and then start the tunnel on the client, all is well. However, after I close that first MySQL client connection, I cannot start another. Tcpdump reveals that the client is passing no packets to the server."

    	server$ stunnel -d 3307 -r localhost:3306
    	client$ stunnel -c -d 3306 -r 192.168.1.2:3307
    	

    Solution: The problem below is caused by proplems with linux kernel 2.2.14 and MySQL. Some of the networking code appears to be a bit dodgy. This is fixed in 2.2.16.

    The fix? Upgrade your kernel past 2.2.14. 2.2.16 works for me.

    PS, I am indebted to the post by Sergey Yegorov to mailing.database.mysql who had a related problem with the mysqld server, and who wrote a detailed enough message to be let me recognise this similar problem with the mysql client.


    I'm running Stunnel via inetd, but it's not using all the arguments I specified

    Some OSs only allow a certain number of program arguments in the inetd.conf line. Solaris only allows 5, for example. Your best options include:

    • Joining flags that take options (such as '-l/usr/sbin/in.telnetd' instead of '-l /usr/sbin/in.telnetd') to concerve inetd arguments, or
    • create a shell script that runs your Stunnel program with the correct arguments and have inetd launch that script instead of stunnel directly.


  • Stunnel hangs for a while accepting connections

    Solution: You probably have TCP Wrapper support compiled into Stunnel, and are having DNS problems. TCP Wrappers do reverse lookups of the incoming IP address. If you have a bad server in /etc/resolv.conf and this query fails then it'll take time before the resolver will go to the next one, and Stunnel will wait. We suggest any or all of the following:
    • Fix your /etc/resolv.conf
    • Make sure your machines have reverse DNS entries. It's just a good practice anyway.
    • Try accessing a closer name server first in your resolv.conf
    • Consider running a caching nameserver on your local host and pointing to it first
    If the problem doesn't go away, you may want to try compiling Stunnel without TCP Wrappers and see if the problem is still there and troubleshoot further.


  • Stunnel is complaining that there are too many open files and is refusing new connections

    Sulution:This is an OS-dependent issue. You probably have a hard limit of the number of file descriptors that can be open by processes. Increase this number to a more acceptable level. Stunnel may use anywhere from one to four file descriptors per connection depending on how you're using it.

    For a quick glance at how to change this parameter on Solaris, go here.


  • My connections are slow, slow, slow

    One option might be to turn on the TCP NODELAY option on both ends. On the server, include the following options:
    	-O l:TCP_NODELAY=1
    	
    and on the client include
    	-O r:TCP_NODELAY=1
    	


  • Are there any special problems with Stunnel and IE?

    Per Mike:
    It's a well known problem with Internet Explorer and several other products. They don't send close_notify message before TCP FIN packet violating SSLv3 and TLSv1 protocols. It is also a security problem: Microsoft applications are vulnerable to truncation attacks. Is Microsoft able to implement anything properly?

    Currently stunnel implements ugly 10-seconds timeout to work with Microsoft... I hate it, but several peple need it.

    See RFC 2246 chapter 7.2.1. for details.


  • I'm running out of processes/file descriptors

    From Mike:
    How can I increase the number of file descriptors per process in Solaris?

    In 2.3 in earlier this requires poking the kernel. In Solaris 2.4+, this can be accomplished by adding the following lines to /etc/system:

    	* set hard limit on file descriptors
    	set rlim_fd_max = 4096
    	* set soft limit on file descriptors
    	set rlim_fd_cur = 1024
    	

    Raising the soft limit past 256 may confuse certain applications, especially BCP applications. Raising the limit past 1024 may confuse applications that use select(). Select() cannot use more than 1024 file descriptors at this time prior to Solaris 7. In Solaris 2.6, the RPC code was rewritten to use poll(), which does work with many more fds than select(). Prior to 2.6, all RPC servers will likely crash and burn if you increase the fd soft limit past 1024.

    Solaris 7 allows upto 65536 fds passed to select; this is the default for 64 bit applications but it requires recompiling with a larger value for FD_SETSIZE for 32 bit apps.

    Change FD_SETSIZE value in your system headers (select.h) to whatever value you consider safe and rebuild Stunnel (make clean; make; make install).

    -Mike

    From Franz Glasner:
    > I am running stunnel on solaris 8. I want to increase the maximum of
    > clients allowed above 500. I already changed in /etc/system set
    > rlim_fd_max = 8192 and set rlim_fd_cur = 4096. But I don't get above
    > 500. I think the limiting factor is FD_SETSIZE. I don't know how to
    > change that. Can anyone help me?

    This is to be done at compile time. Add the compiler option

        -DFD_SETSIZE=4096
    
    and compile stunnel again.

    Franz.


  • The logs aren't going where they should be in Digital Unix

    Victor Danilchenko found that logs for Stunnel were correctly going to mail.log, as he'd configured, but then started going to user.log after new threads were created, and believes that the syslog functions in Digital Unix 4.0d aren't thread safe. He created a patch that can fix this problem.


  • I can't understand these networking errors on my Windows machine

    If you get errors that look like this:
    bind: Unknown error (10049)
    and don't know offhand what error 10049 is (for example) then you can blame M$ for not providing helpful error text such as is available with perror() on Unix systems. However you can check http://www.sockets.com/err_lst1.htm which has a list of common error codes.


  • TCP Wrappers aren't working right

    If you are using Stunnel in a chroot environment, you'll need to include the /etc/hosts.allow and /etc/hosts.deny files within that environment. So say your stunnel.conf had the following:
    	chroot = /path/to/chroot/
    Then you'd need to create /path/to/chroot/etc and put your hosts.allow and hosts.deny files there:
    	mkdir /path/to/chroot/etc
    	cp /etc/hosts.allow /etc/hosts.deny /path/to/chroot/etc
    	
    Make sure that you change these files, not the global /etc/hosts.{allow.deny} files.


  • My web browser can't talk to Stunnel

    If you get the following error message in Stunnel:

    2003.01.18 17:46:07 LOG3[6093:32770]: SSL_accept: 1407609C: error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request

    then you have Stunnel running as a daemon mode, not client mode (no -c for 3.x, or you have client=no for 4.x) and your web browser is connecting to it as if it's a normal webserver, ala http://example.com/.

    If Stunnel is supposed to be running as a client, then fix your commandline args or stunnel.conf. If you do mean to be running as a daemon (SSL server) then point your browser at https://host:port/ instead of http://host:port/


  • Problems tunneling telnet over Stunnel with AIX

    First of all, why are you doing this instead of just using OpenSSH which is much better anyway???

    Petr Vandrovec notes that

    we had to start telnetd with 'telnetd -a' on our AIXes if we feed data to it through stunnel. For some strange reason AIX's telnet daemon just decides to throw data away if you do not read them quickly enough - for example cat-ting 20MB file full of zeroes was transfered as 5MB of zeroes to client. And no, it is not caused by stunnel, but by 4.3.2 telnetd.

    Eric Eberhard suggests uning including -R as an alternate solution.


  • Eudora keeps saying "error reading network"

    Dave Gardner suggests the following:

    It's a timing error in Eudora, not a problem in stunnel. In Eudora, go to "Tools" -> "Options". Scroll down and select "Advanced Network". Increase the "Network Buffer Size" to 8192. Put a check mark in "Cache network info". If you want to increase "Network open timeout" and "Network timeout after" values too, it wouldn't hurt (try 1000). Then try to collect email again. Should work for you.
    And Frank Notspak reports success setting "Network Buffer Size" to 32000.

    You might also want to try including

    options = DONT_INSERT_EMPTY_FRAGMENTS

    in your stunnel.conf.


  • I'm running Stunnel 3.x as a service, but it dies on logoff

    Remove the following code from stunnel.c (located in CtrlHandler(DWORD fdwCtrlType)) and recompile

      case CTRL_LOGOFF_EVENT:
            log(LOG_NOTICE, "Process exit: user logoff");
            break;