Skip to content

Commit 719ca2c

Browse files
committed
When initializing an instance of X509Certificate2 supply null as the password if one hasn't been set instead of an empty string.
1 parent 6f4264a commit 719ca2c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

JdSoft.Apple.Apns.Feedback/FeedbackService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public FeedbackService(string host, int port, byte[] p12FileBytes)
8787
// The default is UserKeySet, which has caused internal encryption errors,
8888
// Because of lack of permissions on most hosting services.
8989
// So MachineKeySet should be used instead.
90-
certificate = new X509Certificate2(p12FileBytes, "", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
90+
certificate = new X509Certificate2(p12FileBytes, null, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
9191
ConnectAttempts = 3;
9292
ReconnectDelay = 10000;
9393
}
@@ -126,7 +126,7 @@ public FeedbackService(string host, int port, byte[] p12FileBytes, string p12Fil
126126
// The default is UserKeySet, which has caused internal encryption errors,
127127
// Because of lack of permissions on most hosting services.
128128
// So MachineKeySet should be used instead.
129-
certificate = new X509Certificate2(p12FileBytes, p12FilePassword ?? "", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
129+
certificate = new X509Certificate2(p12FileBytes, p12FilePassword, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
130130
P12FilePassword = p12FilePassword;
131131
ConnectAttempts = 3;
132132
ReconnectDelay = 10000;
@@ -160,7 +160,7 @@ public FeedbackService(bool sandbox, byte[] p12FileBytes)
160160
// The default is UserKeySet, which has caused internal encryption errors,
161161
// Because of lack of permissions on most hosting services.
162162
// So MachineKeySet should be used instead.
163-
certificate = new X509Certificate2(p12FileBytes, "", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
163+
certificate = new X509Certificate2(p12FileBytes, null, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
164164
ConnectAttempts = 3;
165165
}
166166

@@ -196,7 +196,7 @@ public FeedbackService(bool sandbox, byte[] p12FileBytes, string p12FilePassword
196196
// The default is UserKeySet, which has caused internal encryption errors,
197197
// Because of lack of permissions on most hosting services.
198198
// So MachineKeySet should be used instead.
199-
certificate = new X509Certificate2(p12FileBytes, p12FilePassword ?? "", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
199+
certificate = new X509Certificate2(p12FileBytes, p12FilePassword, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
200200
P12FilePassword = p12FilePassword;
201201
ConnectAttempts = 3;
202202
ReconnectDelay = 10000;
@@ -231,7 +231,7 @@ public void Run()
231231
// The default is UserKeySet, which has caused internal encryption errors,
232232
// Because of lack of permissions on most hosting services.
233233
// So MachineKeySet should be used instead.
234-
certificate = new X509Certificate2(System.IO.File.ReadAllBytes(P12File), P12FilePassword ?? "", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
234+
certificate = new X509Certificate2(System.IO.File.ReadAllBytes(P12File), P12FilePassword, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
235235
}
236236

237237
certificates = new X509CertificateCollection();

JdSoft.Apple.Apns.Notifications/NotificationChannel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public NotificationChannel(string host, int port, byte[] p12FileBytes, string p1
195195
// The default is UserKeySet, which has caused internal encryption errors,
196196
// Because of lack of permissions on most hosting services.
197197
// So MachineKeySet should be used instead.
198-
certificate = new X509Certificate2(p12FileBytes, p12FilePassword ?? "", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
198+
certificate = new X509Certificate2(p12FileBytes, p12FilePassword, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
199199

200200
certificates = new X509CertificateCollection();
201201
certificates.Add(certificate);

0 commit comments

Comments
 (0)