uruk-project / Jwt

JSON Web Token implementation for .Net & .Net Core
MIT License
82 stars 13 forks source link

Fix creation of asymmetric keys from certificates with private key #451

Closed lochgeo closed 4 years ago

lochgeo commented 4 years ago

Added a test as described in issue #450. This results in 4 cases (public keys) passing and 4 cases (certs with private keys) failing.

lochgeo commented 4 years ago

Now added code to make the test pass. Firstly in the test case fixtures, added the X509KeyStorageFlags.Exportable so that we can extract the private keys later. And then in the source jwk.cs made rsa.ExportParameters(true) and ecdsa.ExportParameters(true)

lochgeo commented 4 years ago

I have applied your suggestions now, but maybe later the FromX509Certificate() method needs to be refactored as there is some duplicate blocks of code.