Получение ошибки при отправке уведомления на iOS от ASP.NET с#
получение ошибки как " аутентификация не удалась, так как удаленная сторона закрыла транспортный поток."
Что я уже пробовал:
int port = 2195; string hostname = "gateway.sandbox.push.apple.com"; // String hostname = "gateway.push.apple.com"; String certificatePath = Server.MapPath("PushnotificationDev.p12"); X509Certificate2 clientCertificate = new X509Certificate2(System.IO.File.ReadAllBytes(certificatePath), "password"); X509Certificate2Collection certificatesCollection = new X509Certificate2Collection(clientCertificate); TcpClient client = new TcpClient(hostname, port); SslStream sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null); try { // client.Connect(hostname,port); //sslStream.AuthenticateAsServer(hostname, certificatesCollection, SslProtocols.Default, true); ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3; sslStream.AuthenticateAsServer(clientCertificate, false, SslProtocols.Ssl3, true); MemoryStream memoryStream = new MemoryStream(); BinaryWriter writer = new BinaryWriter(memoryStream); writer.Write((byte)0); writer.Write((byte)0); writer.Write((byte)32); writer.Write(ConvertToByteArray("9865ac6c888e9b9e819b15772e6bcb11d64c659d331a28cf7674050a20fa895p")); String payload = "{\"aps\":{\"alert\":\"" + "Hi,, This Is a Sample Push Notification For IPhone.." + "\",\"badge\":1,\"sound\":\"default\"}}"; writer.Write((byte)0); writer.Write((byte)payload.Length); byte[] b1 = System.Text.Encoding.UTF8.GetBytes(payload); writer.Write(b1); writer.Flush(); byte[] array = memoryStream.ToArray(); sslStream.Write(array); sslStream.Flush(); client.Close(); } catch (System.Security.Authentication.AuthenticationException ex) { client.Close(); } catch (Exception ex) { lblenc.Text = ex.Message; client.Close(); }