Compare commits

..

No commits in common. "d3084026672ab5a4a8393213583994bc4f9529f8" and "a77ae1baedfc9d962313efaecce6108ced315d2d" have entirely different histories.

View File

@ -16,20 +16,9 @@ public class PushServiceWithP12
public PushServiceWithP12(string keysFilePath, string p12Path, string apnsTopic) public PushServiceWithP12(string keysFilePath, string p12Path, string apnsTopic)
{ {
// 존재 안하면 예외 던져 버리는거
if (!File.Exists(keysFilePath))
{
Console.WriteLine($"File not found: {keysFilePath}");
throw new FileNotFoundException("The specified file was not found", keysFilePath);
}
var keys = JsonSerializer.Deserialize<Dictionary<string, string>>(File.ReadAllText(keysFilePath)); var keys = JsonSerializer.Deserialize<Dictionary<string, string>>(File.ReadAllText(keysFilePath));
// TEST // TEST
Console.WriteLine("Keys content:"); Console.WriteLine($"File Exists: {keys}");
foreach (var key in keys)
{
Console.WriteLine($"{key.Key}: {key.Value}");
}
p12Password = keys["Password"]; p12Password = keys["Password"];
this.p12Path = p12Path; this.p12Path = p12Path;
@ -58,10 +47,9 @@ public class PushServiceWithP12
try try
{ {
var certificate = new X509Certificate2(p12Path, p12Password, var certificate = new X509Certificate2(p12Path, p12Password,
X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
);
handler.ClientCertificates.Add(certificate); handler.ClientCertificates.Add(certificate);
Console.WriteLine("Certificate successfully loaded.");
} }
catch (CryptographicException ex) catch (CryptographicException ex)
{ {