服务器(java)无法从具有SSL连接的客户端(c)接收XML
我正在尝试将XML从客户端发送到服务器。我使用System.Security.Cryptography.X509Certificates来使用它;并在AuthenticateClient中调用了异常。例外是 捕获了AutIdenticationException,对SSPI的调用失败,请参阅内部 例外 这是我的代码:服务器(java)无法从具有SSL连接的客户端(c)接收XML,java,c#,xml,ssl,Java,C#,Xml,Ssl,我正在尝试将XML从客户端发送到服务器。我使用System.Security.Cryptography.X509Certificates来使用它;并在AuthenticateClient中调用了异常。例外是 捕获了AutIdenticationException,对SSPI的调用失败,请参阅内部 例外 这是我的代码: public static SslStream OpenSSL(string _IP, int _port) { try { TcpClient c
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。我被困在这里两天了,有人知道这个问题出了什么问题吗
注意:我使用VS2010客户端和EclipseMarsforLinux服务器尝试添加此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
如果没有帮助,我也不知道:谢谢你的回答。但是它不工作,服务器仍然没有接收XML