Re: Installation of Blat

"'Chip' [email protected] [blat]" <[email protected]> Sun, 19 Nov 2017 13:46:02 -0800
Newsgroups gmane.mail.blat
Message-ID <20E72BD1CCE64D13A123A3571F8AF906@chip>
> So, after having successfully installed stunnel on my main machine (Windows 7 64 Bit) I am now trying to port the Installation (Blat and stunnel) to my laptop (Windows 10 64 Bit). 
>
> I did run the stunnel installer, answered the questions, created a cert file, and added the following lines to the conf file (same as on the other machine):
>
> [mypos smtp]
> accept = 25
> connect = smtp.mypos.com:26
> protocol = smtp
>
> Next, I started the stunnel service, and set the stunnel service to automatic start.
> Blat is configure in registry with Base64 Coded login data, Name of sender email, SMTP Port 25, SMTP Server localhost (or 127.0.0.1, tried both).

> No success ....
> Blat log file shows:
>
> Error: Connection to server was dropped.
> *** Error ***  SMTP server error
> Error: Not a socket.
> Error: Not a socket.
> ERROR: File name (message text) not given or Bad argument given, Unable to open SMTP socket, SMTP get line did not return 220, command unable to write to socket, Server does not like To: address or Mail server error accepting message data.
>
>
> Next step : Searching for an stunnel log. Took me a while that i have to run stunnel all users - stunnel gui start, to get to the following:
>
> [ ] Running on Windows 6.2
> [ ] No limit detected for the number of clients
> [.] stunnel 5.43 on x86-pc-msvc-1500 platform
> [.] Compiled/running with OpenSSL 1.0.2m-fips  2 Nov 2017
> [.] Threading:WIN32 Sockets:SELECT,IPv6 TLS:ENGINE,FIPS,OCSP,PSK,SNI
> [ ] errno: (*_errno())
> [ ] GUI message loop initialized
> [ ] Running on Windows 6.2
> [.] Reading configuration from file stunnel.conf
> [.] UTF-8 byte order mark detected
> [.] FIPS mode disabled
> [ ] Compression disabled
> [ ] PRNG see! ded successfully
> [ ] Initializing service [bbtthailand smtp]
> [ ] Ciphers: HIGH:!DH:!aNULL:!SSLv2
> [ ] TLS options: 0x03000004 (+0x03000000, -0x00000000)
> [ ] Loading certificate from file: stunnel.pem
> [ ] Certificate loaded from file: stunnel.pem
> [ ] Loading private key from file: stunnel.pem
> [ ] Private key loaded from file: stunnel.pem
> [ ] Private key check succeeded
> [:] Service [mypos smtp] needs authentication to prevent MITM attacks
> [.] Configuration successful
> [ ] Binding service [mypos smtp]
> [ ] Listening file descriptor created (FD=664)
> [ ] Option SO_EXCLUSIVEADDRUSE set on accept socket
> [!] bind: Address already in use (WSAEADDRINUSE) (10048)
> [!] Error binding service [mypos smtp] to 127.0.0.1:25
> [ ] Unbinding service [bbtthailand smtp]
> [ ] Service [bbtthailand smtp] closed
>
> [!] Server is down
>
> What next?


I searched for the message “Error binding service” as related to Stunnel, and found what I believe the most likely issue is that Windows Firewall may need to be told to allow Stunnel.

However, as was suggested by Jeroen, it is possible that another program is actively listening on port 25.  It is possible to know this if you open a command prompt window, run “netstat –ab”, and look for 127.0.0.1:25 in the output.  If that ip:port is listed in your output, the line below it will show which program has control of the port.  You can configure stunnel and blat to use a different port number rather than port 25, such as port number 125 (I use 8002 for one of my connections).

The rest of this discussion relates to Windows Firewall ---

https://serverfault.com/questions/479031/stunnel-cant-bind-to-0-0-0-0

That answer lead to searching how to open a port in the Windows firewall, under program control:
https://stackoverflow.com/questions/802687/what-api-calls-are-involved-in-opening-a-port-in-the-windows-firewall

This in turn gave https://technet.microsoft.com/en-us/library/cc771046%28v=ws.10%29.aspx#bkmk_addallowedprogram

I started to use the old form for netsh, but Windows complained that I needed to use the newer format:
https://support.microsoft.com/en-us/help/947709/how-to-use-the-netsh-advfirewall-firewall-context-instead-of-the-netsh

Here is what works for my Windows 7 system with Stunnel version 5.43 installed to C:\stunnel directory.

netsh advfirewall firewall add rule name="stunnel (GUI Version)" dir=in action=allow program="C:\stunnel\bin\stunnel.exe" enable=yes
netsh advfirewall firewall add rule name="stunnel (Terminal Version)" dir=in action=allow program="C:\stunnel\bin\tstunnel.exe" enable=yes

-- 
Chip