Search code examples
sharpssh

Is Tamir.SharpSSH Windows Server 2012 Compatible?


We recently moved an application that uses Tamir.SharpSSH from a Windows 2003 server to Windows Server 2012.

While testing the SFTP functionality of our app we received this error:

{"Session.connect: System.NullReferenceException: Object reference not set to an instance of an object.\r\n at Tamir.SharpSsh.jsch.jce.HMACMD5.update(Byte[] foo, Int32 s, Int32 l)\r\n at Tamir.SharpSsh.jsch.jce.HMACMD5.update(Int32 i)\r\n at Tamir.SharpSsh.jsch.Session.read(Buffer buf)\r\n at Tamir.SharpSsh.jsch.UserAuth.start(Session session)\r\n at Tamir.SharpSsh.jsch.UserAuthNone.start(Session session)\r\n at Tamir.SharpSsh.jsch.Session.connect(Int32 connectTimeout)"}

I checked to make sure that the FIPS Compliant Algorithms are disabled and they are.

We then removed the DLL reference to Tamir.SharpSSH from the project and added the source code project, to where we are now able to step into the code to determine more specifically where the failure is occurring in the SharpSSH library.

The error is occurring at cs.Write(foo, s, l) in the update() method as shown below:

    public void update(byte[] foo, int s, int l) { cs.Write( foo, s, l); }

This is because the cs object reference is NULL.

The cs object reference is supposed to be set in the init() method of HMACMD5.cs (last line), however it doesn't appear that this method is getting called.

public void init(byte[] key)
    {
        if(key.Length>bsize)
        {
            byte[] tmp=new byte[bsize];
            Array.Copy(key, 0, tmp, 0, bsize);    
            key=tmp;
        }
        //    SecretKeySpec skey=new SecretKeySpec(key, "HmacMD5");
        //    mac=Mac.getInstance("HmacMD5");
        //    mac.init(skey);
        mentalis_mac = new Org.Mentalis.Security.Cryptography.HMAC(new System.Security.Cryptography.MD5CryptoServiceProvider(), key);
        cs = new System.Security.Cryptography.CryptoStream( System.IO.Stream.Null, mentalis_mac, System.Security.Cryptography.CryptoStreamMode.Write);
    } 

I'm not exactly sure why the init() method is not being called though.

Has anyone experienced something like this?

I'm wondering if it might be a Windows Server 2012 Compatibility issue.

Thanks in advance.


Solution

  • I found that I was missing a reference to Org.Mentalis.Security.

    As soon as I added that, everything worked fine.

    Thanks