ms-iot / azure-client-tools

Azure Client Tools
Other
43 stars 37 forks source link

Fix leap year bug in LimpetIssueCertificate #55

Closed mattjohnsonpint closed 4 years ago

mattjohnsonpint commented 4 years ago

The LimpetIssueCertificate function was setting the certificate expiration date by adding 10 years, not correctly accounting for leap year. In other words, if this function was called on 2020-02-29, it would attempt to create a certificate with the expiration date of 2030-02-29, which doesn't exist because 2030 is not a leap year. (CryptSignAndEncodeCertificate will fail when passed such a date.)

This code corrects Feb 29th back to Feb 28th when the resulting year is not a leap year.