C# 使用mono和ubuntu连接gateway.sandbox.push.apple.com时出错

C# 使用mono和ubuntu连接gateway.sandbox.push.apple.com时出错,c#,ios,ssl,mono,push-notification,C#,Ios,Ssl,Mono,Push Notification,我正在尝试连接到apns并获取异常:从服务器接收到无效证书。我发现一个可能的解决方案是禁用验证,但它不起作用: ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, ssl) => true; 发现的另一个解决方案是向mono添加证书,因为mono存储默认为空, 但也不起作用: certmgr -ssl https://gateway.sandbox.push.apple.com

我正在尝试连接到apns并获取异常:从服务器接收到无效证书。我发现一个可能的解决方案是禁用验证,但它不起作用:

ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, ssl) => true;
发现的另一个解决方案是向mono添加证书,因为mono存储默认为空, 但也不起作用:

certmgr -ssl https://gateway.sandbox.push.apple.com 
以下是要连接的代码:

 //load certificate
        var clientCertificate = new X509Certificate2 ("cert.pem", "xxx");
        var clientCertificate2 = new X509Certificate2 ("entrust_ca.pem");
        var certificatesCollection = new X509Certificate2Collection();
        certificatesCollection.Add (clientCertificate);
        certificatesCollection.Add (clientCertificate2);
        ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, ssl) => true;

        var client = new TcpClient(hostname, port);
        var sslStream = new SslStream (client.GetStream (), false);

        try
        {
            sslStream.AuthenticateAsClient(hostname, certificatesCollection, SslProtocols.Default, false); //crash here
        }
        catch (Exception ex)
        {
            Console.WriteLine (ex);
            //client.Close();
            //return;
        }
有什么想法吗