Search code examples
c#windows-servicesapple-push-notificationsrsapushsharp

How to remove machinekeyset from APNSConfiguration?


I am using PushSharp in my .net Windows Service to send Push Notification to Android, iOS, and BlackBerry.

After calling below line:

apnsConfig = new ApnsConfiguration(appleServerEnv, appleCert, ConfigurationManager.AppSettings["iOSProdCertPassword"]);

Under following location

C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys

one machine is generated, this keep on growing. Is there any way to stop generating this key.

Its given in the below link that removing machinekeyset from APNS Configuration will fix the issue

[https://github.com/Redth/PushSharp/issues/580][1]

X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable from the ApnsConfiguration

How to add above code in PushSharp?


Solution

  • By instantiating ApnsConfiguration object in the following way, I stopped generating the MachineKey files and Push is also working:)

     var certf = X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable;
    
     var certificate = new X509Certificate2(
                                    appleCert, "CertificatePassword", certf);
    
    
     apnsConfig = new ApnsConfiguration(appleServerEnv, certificate);