Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/145.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
服务器(java)无法从具有SSL连接的客户端(c)接收XML_Java_C#_Xml_Ssl - Fatal编程技术网

服务器(java)无法从具有SSL连接的客户端(c)接收XML

服务器(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

我正在尝试将XML从客户端发送到服务器。我使用System.Security.Cryptography.X509Certificates来使用它;并在AuthenticateClient中调用了异常。例外是

捕获了AutIdenticationException,对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。我被困在这里两天了,有人知道这个问题出了什么问题吗

注意:我使用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