[🐛] 5차 푸시 확인

Signed-off-by: seonkyu.kim <sean.kk@daum.net>
This commit is contained in:
김선규 2024-11-30 02:55:12 +09:00
parent d52ef4ff02
commit 0634f8f156
2 changed files with 23 additions and 8 deletions

View File

@ -38,14 +38,14 @@ public class PushController : ControllerBase
if (_env.IsDevelopment())
{
uri = "https://api.sandbox.push.apple.com";
p12FilePath = "/volume1/AcaMate/PROJECT/Application/Back/private/AM_Push_Sandbox.p12";
// "private/AM_Push_Sandbox.p12";
p12FilePath = "/volume1/AcaMate/PROJECT/Application/Back/private/AM_Push_Sandbox.pfx";
// p12FilePath = "private/AM_Push_Sandbox.p12";
}
else
{
uri = "https://api.push.apple.com";
p12FilePath = "/volume1/AcaMate/PROJECT/Application/Back/private/AM_Push.p12";
// "private/AM_Push.p12";
p12FilePath = "/volume1/AcaMate/PROJECT/Application/Back/private/AM_Push.pfx";
// p12FilePath = "private/AM_Push.p12";
}
var apnsTopic = "me.myds.ipstien.acamate.AcaMate";

View File

@ -1,5 +1,6 @@
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Text.Json;
@ -37,12 +38,26 @@ public class PushServiceWithP12
};
var jsonPayload = JsonSerializer.Serialize(payload);
var certificate = new X509Certificate2(p12Path, p12Password,
X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable
);
var handler = new HttpClientHandler();
handler.ClientCertificates.Add(certificate);
try
{
var certificate = new X509Certificate2(p12Path, p12Password,
X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
handler.ClientCertificates.Add(certificate);
}
catch (CryptographicException ex)
{
Console.WriteLine($"CryptographicException: {ex.Message}");
}
catch (Exception ex)
{
Console.WriteLine($"Unexpected error: {ex.Message}");
}
using var client = new HttpClient(handler)
{