Recent

Author Topic: Cryptlib - Network subsystem is unusable, 10091  (Read 8422 times)

Gizmo

  • Hero Member
  • *****
  • Posts: 831
Cryptlib - Network subsystem is unusable, 10091
« on: February 27, 2015, 12:34:15 am »
OK, I am about to launch myself off a bridge!!

First I had troubles being able to send e-mails with attachments using Synapse and the SMTPSend unit, but eventually got that working and posted this thread in response : http://forum.lazarus.freepascal.org/index.php/topic,27222.msg168096.html#msg168096

Then I wanted to add the ability to FTP connect and send files using an encrypted FTP service like sFTP. To do that, I needed to use a  a Pascal variant of cryptlib (http://cryptlib.sogot.de/crypas.html), add another DLL (cl32.dll), added blcksock unit, and finally SimpleSFTP from http://synapse.ararat.cz/files/contrib/sftp.zip.

After much struggling and fiddling, I eventually got standard FTP to work and although I am yet to test my sFTP connection, I have some compiled code that should hopefully work. I accept that Cryptlib is not officially part of Lazarus and Freepascal so this probably my fault, but it was the only way I could find to use encrypted sFTP with my program (http://forum.lazarus.freepascal.org/index.php/topic,27488.msg169927.html#msg169927) in the lack of any other built in solution.

So, celebrating my progress with FTP and sFTP, I then returned to refine my e-mail issuing code but what do I find? Now that won't work again, because, as far I can tell, Cryptlib is somehow conflicting with ssl_openssl.

Whenever I get to the login code, the login fails.

Code: [Select]
...
function TForm1.SendMail(User, Password, MailFrom, MailTo, SMTPHost, SMTPPort: string;
  MailData: string): Boolean;   
 try
    sl.text:=Maildata;
    SMTP.UserName   := User;
    SMTP.Password   := Password;
    SMTP.TargetHost := SMTPHost;
    SMTP.TargetPort := SMTPPort;
    SMTP.AutoTLS    := false;
    SMTP.FullSSL    := true;

    if Trim(SMTPPort)<>'25' then
      SMTP.FullSSL:=true;   // the two DLLs needed and bundled from https://sourceforge.net/projects/openssl-net/files/openssl-net/0.5/

    if SMTP.Login then   <-- THIS ALWAYS FAILS NOW, but it worked before adding Cryptlib. Now it generates the "Network subsystem is unusable", code 10091 values
    begin
      result:=SMTP.MailFrom(MailFrom, sl.Count) and
      SMTP.MailTo(MailTo) and
      SMTP.MailData(sl);
      SMTP.Logout;
    end;
...   

Routing through the debugger I find the following:

function TTCPBlockSocket.GetErrorDescEx: string;
begin
  Result := inherited GetErrorDescEx;
  if (FLastError = WSASYSNOTREADY) and (self.SSL.LastError <> 0) then
  begin
    Result := self.SSL.LastErrorDesc; 
      // Result = "Network subsystem is unusable, 10091" and
      // self.SSL.LastErrorDesc = "Received TLS alert message: Decode error"
  end;
end; 

http://wiki.rocrail.net/doku.php?id=win32-socket-error states "WSASYSNOTREADY  10091  : Returned by WSAStartup(), indicating that the network subsystem is unusable".

According to https://www.openssl.org/docs/ssl/SSL_alert_type_string.html, decode error means : A message could not be decoded because some field was out of the specified range or the length of the message was incorrect. This message is always fatal.

Further Googling implies this is an issue with Cryptlib, which I have to use for FTP. If I take it out, e-mail will work but FTP will not.

I have re-downloaded the DLL's from http://indy.fulgan.com/SSL/ (ssleay32.dll and libeay32.dll)

I am at a loss.
« Last Edit: February 27, 2015, 01:00:01 am by Gizmo »

 

TinyPortal © 2005-2018