Skip to content

Commit

Permalink
Merge pull request Redth#15 from Danielgindi/patch-3
Browse files Browse the repository at this point in the history
Edited JdSoft.Apple.Apns.Feedback/FeedbackService.cs via GitHub
  • Loading branch information
Redth committed Oct 7, 2011
2 parents 36a3de6 + 5428b78 commit 29dd515
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions JdSoft.Apple.Apns.Feedback/FeedbackService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 29dd515

Please sign in to comment.