I want to consume the APNs push service in my application so i use this code:
var responseString = string.Empty;
using (var request = new HttpClient(new Http2CustomHandler()))
{
var content = new StringContent(body);
request.DefaultRequestHeaders.Add("authorization", $"bearer {authorization}");
request.DefaultRequestHeaders.Add("apns-topic", topicName);
if (!string.IsNullOrWhiteSpace(iD)) request.DefaultRequestHeaders.Add("apns-id", iD);
if (!string.IsNullOrWhiteSpace(expiration)) request.DefaultRequestHeaders.Add("apns-expiration", expiration);
if (!string.IsNullOrWhiteSpace(priority)) request.DefaultRequestHeaders.Add("apns-priority", priority);
if (!string.IsNullOrWhiteSpace(collapseID)) request.DefaultRequestHeaders.Add("apns-collapse-id", collapseID);
var result = request.PostAsync(url, content).GetAwaiter().GetResult();
responseString = result.Content.ReadAsStringAsync().GetAwaiter().GetResult();
}
its working just fine on my machine(windows 10). but when i deploy the application on my server(windows server 2012 R2) it throws this exception:
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.Http.WinHttpException: A security error occurred
is there any way to solve this problem?