I am using PushSharp to send Apple Push Notification in C# , i have my production .pem file and its password. Below is my code snippet.Am always getting this error ..
"A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: The message received was unexpected or badly formatted-"
OR
"System.IO.IOException: Authentication failed because the remote party has closed the transport stream."
I tried almost all codes available in net.Even tried MoonAPNS but same error, For custom script also am getting this SSPI failure error. I use the same .pem file and run a php script to send push notification to APN from same server,it works.
var push = new PushBroker();
var appleCert = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ck.pem"));
push.RegisterAppleService(new ApplePushChannelSettings(false, appleCert, "pwd"));
push.QueueNotification(new AppleNotification()
.ForDeviceToken("XXXXXXXXXXXXXXX")
.WithAlert("Hello World!")
.WithBadge(7)
.WithSound("sound.caf"));
LogManager.Info("Waiting for Queue to Finish..");
push.StopAllServices();
Please help Thanks in advance
I think your c# may be incorrect, To verify, rather than with a .pem, can you try with your p12 cert using the below code as a test...