1

我有一些调用肥皂服务的代码。
它在我的第一台 linux 机器上运行良好。
但是,当我在另一台机器上运行它时,出现以下错误。
谷歌似乎表明它可能来自证书,尽管我不确定这一点,因为我正在通过ServicePointManager.ServerCertificateValidationCallback = Validator; Where Validatoris a function that return true 覆盖证书方法。

有任何想法吗?

Unhandled Exception: System.Net.WebException: Error getting response stream (ReadDone1): ReceiveFailure ---> System.IO.IOException: EndRead failure ---> System.Net.Sockets.SocketException: Connection reset by peer
  at System.Net.Sockets.Socket.EndReceive (IAsyncResult result) [0x00000] in <filename unknown>:0 
  at System.Net.Sockets.NetworkStream.EndRead (IAsyncResult ar) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Net.Sockets.NetworkStream.EndRead (IAsyncResult ar) [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.SslStreamBase.InternalReadCallback (IAsyncResult result) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
  at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0 
  at CRMOnlineSOAPRequests.CRMHelper.GetSOAPResponse (System.String url, System.String soapEnvelope) [0x00000] in <filename unknown>:0 
  at CRMOnlineSOAPRequests.CRMHelper.createEntity (System.String[] keyValuesOneDimensionalArray) [0x00000] in <filename unknown>:0 
  at CRMCreateEntity.Program.Main (System.String[] keyValuesOneDimensionalArray) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.Net.WebException: Error getting response stream (ReadDone1): ReceiveFailure ---> System.IO.IOException: EndRead failure ---> System.Net.Sockets.SocketException: Connection reset by peer
  at System.Net.Sockets.Socket.EndReceive (IAsyncResult result) [0x00000] in <filename unknown>:0 
  at System.Net.Sockets.NetworkStream.EndRead (IAsyncResult ar) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Net.Sockets.NetworkStream.EndRead (IAsyncResult ar) [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.SslStreamBase.InternalReadCallback (IAsyncResult result) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
  at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0 
  at CRMOnlineSOAPRequests.CRMHelper.GetSOAPResponse (System.String url, System.String soapEnvelope) [0x00000] in <filename unknown>:0 
  at CRMOnlineSOAPRequests.CRMHelper.createEntity (System.String[] keyValuesOneDimensionalArray) [0x00000] in <filename unknown>:0 
  at CRMCreateEntity.Program.Main (System.String[] keyValuesOneDimensionalArray) [0x00000] in <filename unknown>:0
4

1 回答 1

0

我们公司的证书有问题,另一家公司希望我们使用在线生成的证书,而不是“官方”证书。我们不想将该证书包含在我们的受信任列表中,因为其他公司也可能使用它。因此,我们使用以下代码临时接受所有证书,然后我们重置证书处理:

System.Net.ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) =>
{
    //Whatever the certificate, accept it.
    return true;
};

//Do your request

//Reset handling to normal.
System.Net.ServicePointManager.ServerCertificateValidationCallback = null;

请注意,这是在 .NET 中而不是单声道中,所以我不确定它是否会起作用。

于 2013-03-15T11:21:29.837 回答