[英]Server (java) can't receive XML from client (c#) with SSL connection
我正在嘗試將XML從客戶端發送到服務器。 我using System.Security.Cryptography.X509Certificates;
並在AuthenticateClient
調用了Exception。 例外是
捕獲了AutenticationException,對SSPI的調用失敗,請參閱內部異常。
這是我的代碼:
public static SslStream OpenSSL(string _IP, int _port)
{
try
{
TcpClient client = new TcpClient(_IP, _port);
// Create a secure stream
SslStream sslStream = new SslStream(client.GetStream(), false,
new RemoteCertificateValidationCallback(ValidateServerCertificate), null);
if (sslStream != null)
{
sslStream.AuthenticateAsClient(_IP);
}
return sslStream;
}
catch (Exception _e)
{
Util.Log.Track(Config.System.LogMode.UTIL, "Comms.Handler.OpenSSL: exception = " + _e.ToString());
return null;
}
}
我可以連接到服務器,但是服務器不會收到XML。 我在這里呆了2天,有人知道這個問題出什么事了嗎?
注意 :我使用VS2010(客戶端)和Eclipse Mars for linux(服務器)
嘗試添加此C#代碼
System.Net.ServicePointManager.ServerCertificateValidationCallback =
((sender, certificate, chain, sslPolicyErrors) => true);
它忽略了SSL驗證的錯誤
然后嘗試另一種方法進行更改
if (sslStream != null)
{
sslStream.AuthenticateAsClient(_IP);
}
對此
X509Certificates.X509Certificate2Collection xc = new X509Certificates.X509Certificate2Collection();
sslStream.AuthenticateAsClient(_IP, xc, Security.Authentication.SslProtocols.Tls, false);
實際上,我不確定SslProtocols標志。 也許SslProtocols.Tls | SslProtocols.Ssl3
SslProtocols.Tls | SslProtocols.Ssl3
如果沒有幫助,我不知道:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.