soldierq / QLicense

A Ready To Use Software Licensing Solution in C#
MIT License
181 stars 93 forks source link

RSA fixes (SHA256) for .NET 4.7.2 (recommended for .NET 4.6 upwards) #9

Closed philstopford closed 2 years ago

philstopford commented 4 years ago

The casts to RSACryptoProvider in the LicenseHandler need to be adjusted for .NET 4.6 and later. In .NET 4.7.2, these break completely due to the deprecation of SHA1 and the cast defaults to this busted algorithm so the code aborts

The fix appears to be to change the private/public key lines of the form:

RSACryptoServiceProvider rsaKey = (RSACryptoServiceProvider)cert.PublicKey.Key;

to :

RSA rsaKey = cert.getRSAPublicKey();