最近,我们将使用Tamir.SharpSSH的应用程序从Windows 2003服务器移至Windows Server 2012。
在测试我们应用的SFTP功能时,我们收到以下错误消息:
{“ Session.connect:System.NullReferenceException:对象引用未设置为对象的实例。\ r \ n位于Tamir.SharpSsh.jsch.jce.HMACMD5.update(Byte [] foo,Int32 s,Int32 l)\在Tamir.SharpSsh.jsch.jce.HMACMD5.update(Int32 i)处为r \ n,在Tamir.SharpSsh.jsch.Session.read(Buffer buf)中为r \ n在Tamir.SharpSsh.jsch.UserAuth中为r \ n。从Tamir.SharpSsh.jsch.UserAuthNone.start开始(会话会话)\ r \ n,在Tamir.SharpSsh.jsch.Session.connect(Int32 connectTimeout)处启动(会话会话)\ r \ n
我检查以确保已禁用FIPS兼容算法。
然后,我们从项目中删除了对Tamir.SharpSSH的DLL引用,并将源代码项目添加到了我们现在可以进入代码的位置,以更具体地确定SharpSSH库中发生故障的位置。
该错误发生在update()方法中的cs.Write(foo,s,l)处,如下所示:
public void update(byte[] foo, int s, int l) { cs.Write( foo, s, l); }
Run Code Online (Sandbox Code Playgroud)
这是因为cs对象引用为NULL。
应该在HMACMD5.cs的init()方法(最后一行)中设置cs对象引用,但是似乎没有调用此方法。
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);
}
Run Code Online (Sandbox Code Playgroud)
我不确定到底为什么不调用init()方法。
有没有人经历过这样的事情?
我想知道这是否可能是Windows Server 2012兼容性问题。
提前致谢。
| 归档时间: |
|
| 查看次数: |
1312 次 |
| 最近记录: |