Hi my project is based on Asp.Net MVC 4.5 and I am having issue while sending blank push notification such that pass added to the user wallet got updated . There's no error in logs and its also working fine while debugging. But when i hard refresh the pass it got updated . It was working but suddenly stopped working recently. I am using following method to send Blank Push / Silent Notification
public void BlankPushNotificationAPNS(string deviceID, string org_key)
{
int port = 2195;
String hostname = "gateway.push.apple.com";
DataObject.Configuration config = ConfigurationRepository.Instance.getCofigurationByOrgKey(org_key);
String certificatePath = HttpContext.Current.Server.MapPath("~/Certificates/") + config.wallet_cert_name;
//Utility.Logger.LogMsg("Certificate Path : " + certificatePath);
byte[] certificateBytes = File.ReadAllBytes(certificatePath);
//using (var webClient = new WebClient())
//{
// certificateBytes = webClient.DownloadData(certificatePath);
//}
//Utility.Logger.LogMsg("Certificate Bytes : " + System.Text.Encoding.UTF8.GetString(certificateBytes));
X509Certificate2 clientCertificate = new X509Certificate2(certificateBytes, config.wallet_cert_password);
X509Certificate2Collection certificatesCollection = new X509Certificate2Collection(clientCertificate);
//X509Certificate cert = GetAppleServerCert(thumbprint);
//Utility.Logger.LogMsg("certificate read");
TcpClient client = new TcpClient(hostname, port);
SslStream sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null);
//Utility.Logger.LogMsg("certificate read ssl");
try
{
//ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
sslStream.AuthenticateAsClient(hostname, certificatesCollection, SslProtocols.Tls, false);
MemoryStream memoryStream = new MemoryStream();
BinaryWriter writer = new BinaryWriter(memoryStream);
writer.Write((byte)0);
writer.Write((byte)0);
writer.Write((byte)32);
writer.Write(StringToByteArray(deviceID.ToUpper()));
String payload = "{\"aps\":\"\"}";
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)
{
Utility.Logger.BlankPushLogger("Method:BlankPushNotificationAPNS,AuthenticationException", ex.Message + ", deviceID_" + deviceID + ", org name " + config.org_name_without_spaces);
client.Close();
}
catch (Exception e)
{
Utility.Logger.BlankPushLogger("Method:BlankPushNotificationAPNS,Exception", e.Message + ", deviceID_" + deviceID + ", org name " + config.org_name_without_spaces);
client.Close();
}
}
Is there some changes done by apple in certificates or something else. Since it's working and stopped recently. Any help is appreciated