forked from Redth/APNS-Sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Redth#15 from Danielgindi/patch-3
Edited JdSoft.Apple.Apns.Feedback/FeedbackService.cs via GitHub
- Loading branch information
Showing
1 changed file
with
28 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,7 +83,11 @@ public FeedbackService(string host, int port, byte[] p12FileBytes) | |
Id = System.Guid.NewGuid().ToString("N"); | ||
Host = host; | ||
Port = port; | ||
certificate = new X509Certificate2(p12FileBytes); | ||
// Fixed by [email protected] : | ||
// The default is UserKeySet, which has caused internal encryption errors, | ||
// Because of lack of permissions on most hosting services. | ||
// So MachineKeySet should be used instead. | ||
certificate = new X509Certificate2(p12FileBytes, "", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable); | ||
ConnectAttempts = 3; | ||
ReconnectDelay = 10000; | ||
} | ||
|
@@ -118,7 +122,11 @@ public FeedbackService(string host, int port, byte[] p12FileBytes, string p12Fil | |
Id = System.Guid.NewGuid().ToString("N"); | ||
Host = host; | ||
Port = port; | ||
certificate = new X509Certificate2(p12FileBytes, p12FilePassword); | ||
// Fixed by [email protected] : | ||
// The default is UserKeySet, which has caused internal encryption errors, | ||
// Because of lack of permissions on most hosting services. | ||
// So MachineKeySet should be used instead. | ||
certificate = new X509Certificate2(p12FileBytes, p12FilePassword ?? "", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable); | ||
P12FilePassword = p12FilePassword; | ||
ConnectAttempts = 3; | ||
ReconnectDelay = 10000; | ||
|
@@ -148,7 +156,11 @@ public FeedbackService(bool sandbox, byte[] p12FileBytes) | |
Id = System.Guid.NewGuid().ToString("N"); | ||
Host = sandbox ? hostSandbox : hostProduction; | ||
Port = 2196; | ||
certificate = new X509Certificate2(p12FileBytes); | ||
// Fixed by [email protected] : | ||
// The default is UserKeySet, which has caused internal encryption errors, | ||
// Because of lack of permissions on most hosting services. | ||
// So MachineKeySet should be used instead. | ||
certificate = new X509Certificate2(p12FileBytes, "", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable); | ||
ConnectAttempts = 3; | ||
} | ||
|
||
|
@@ -180,7 +192,11 @@ public FeedbackService(bool sandbox, byte[] p12FileBytes, string p12FilePassword | |
Id = System.Guid.NewGuid().ToString("N"); | ||
Host = sandbox ? hostSandbox : hostProduction; | ||
Port = 2196; | ||
certificate = new X509Certificate2(p12FileBytes, p12FilePassword); | ||
// Fixed by [email protected] : | ||
// The default is UserKeySet, which has caused internal encryption errors, | ||
// Because of lack of permissions on most hosting services. | ||
// So MachineKeySet should be used instead. | ||
certificate = new X509Certificate2(p12FileBytes, p12FilePassword ?? "", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable); | ||
P12FilePassword = p12FilePassword; | ||
ConnectAttempts = 3; | ||
ReconnectDelay = 10000; | ||
|
@@ -209,13 +225,14 @@ public void Run() | |
encoding = Encoding.ASCII; | ||
|
||
// certificate will already be set if one of the constructors that takes a byte array was used. | ||
if (certificate == null) | ||
{ | ||
if (string.IsNullOrEmpty(P12FilePassword)) | ||
certificate = new X509Certificate2(System.IO.File.ReadAllBytes(P12File)); | ||
else | ||
certificate = new X509Certificate2(System.IO.File.ReadAllBytes(P12File), P12FilePassword); | ||
} | ||
if (certificate == null) | ||
{ | ||
// Fixed by [email protected] : | ||
// The default is UserKeySet, which has caused internal encryption errors, | ||
// Because of lack of permissions on most hosting services. | ||
// So MachineKeySet should be used instead. | ||
certificate = new X509Certificate2(System.IO.File.ReadAllBytes(P12File), P12FilePassword ?? "", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable); | ||
} | ||
|
||
certificates = new X509CertificateCollection(); | ||
certificates.Add(certificate); | ||
|