title: Is Tamir.SharpSSH Windows Server 2012 Compatible?
body: <p>We recently moved an application that uses Tamir.SharpSSH from a Windows 2003 server to Windows Server 2012.</p>
  
  <p>While testing the SFTP functionality of our app we received this error:</p>
  
  <p>{"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)"}</p>
  
  <p>I checked to make sure that the FIPS Compliant Algorithms are disabled and they are.</p>
  
  <p>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.</p>
  
  <p>The error is occurring at cs.Write(foo, s, l) in the update() method as shown below:</p>
  
  <pre><code>    public void update(byte[] foo, int s, int l) { cs.Write( foo, s, l); }
  </code></pre>
  
  <p>This is because the cs object reference is NULL.  </p>
  
  <p>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.</p>
  
  <pre><code>public void init(byte[] key)
      {
          if(key.Length&gt;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);
      } 
  </code></pre>
  
  <p>I'm not exactly sure why the init() method is not being called though.</p>
  
  <p>Has anyone experienced something like this?</p>
  
  <p>I'm wondering if it might be a Windows Server 2012 Compatibility issue.</p>
  
  <p>Thanks in advance.</p>