Problems with Certificate creation
Opened this issue · 0 comments
Hi there,
when MoonAPNS tries to create a certificate I get a strange error:
System.Security.Cryptography.CryptographicException: An internal error occurred.
at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromBlob(Byte[] rawData, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx)
at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte[] rawData, Object password, X509KeyStorageFlags keyStorageFlags)
This error only occurs when using the IIS on Windows Server 2008 R2 and not when testing with Cassini or IIS on Windows 7.
I was already able to fix this error by changing some of the MoonAPNS code. Would it be possible to integrate those changes into the code?
Here is what I changed in PushNotification.cs:
_certificate = string.IsNullOrEmpty(p12FilePassword) ? new X509Certificate(File.ReadAllBytes(p12File)) :
new X509Certificate2(File.ReadAllBytes(p12File), p12FilePassword, X509KeyStorageFlags.MachineKeySet |
X509KeyStorageFlags.PersistKeySet |
X509KeyStorageFlags.Exportable);
For further info see:
http://stackoverflow.com/questions/9951729/x509certificate-constructor-exception
Best regards.