Add ECDsa support in X509SecurityKey and JsonWebKeyConverter.ConvertFromX509SecurityKey#2377
Add ECDsa support in X509SecurityKey and JsonWebKeyConverter.ConvertFromX509SecurityKey#2377keegan-caruso merged 32 commits intoAzureAD:devfrom joegoldman2:fix/1943
X509SecurityKey and JsonWebKeyConverter.ConvertFromX509SecurityKey#2377Conversation
|
I applaud the fix, but ... I think we need a better solution going forward in the future. I am pretty sure we will see more algorithms in the future on certificates (Dilithium e.g.) Problem is probably here with X509Certificate2 and the extension methods. Trying each private key method might be a bit of a performance hit. |
|
I don't think that creating sub-classes is the right solution. In many cases, the algorithm of the key in the certificate is not known in advance and X509Certificate2 certificate = ...;
ECDsa ecdsa = certificate.GetECDsaPrivateKey();
ECDsaSecurityKey key = new ECDsaSecurityKey(ecdsa);And no need for any new Otherwise, I agree that the current fix isn't as future-proof as we'd like, but I think it's a good first fix before perhaps a deeper refactoring. |
|
Similar comment to #2379, can we add tests for this? |
Can you please check the initial comment of this PR? |
|
I can commit an EC cert if that is what you would like to do. I think in-memory certs would also be fine here if we can use them. One less thing to suppress for test data. |
|
I generated a self-signed cert this way: $cert = New-SelfSignedCertificate -DnsName "CN=KeyStoreTestCertificate" -KeyAlgorithm ECDSA_nistP256 -KeyExportPolicy Exportable -CertStoreLocation Cert:\CurrentUser\My
$cert | Export-PfxCertificate -FilePath "Certificate.pfx" -Password (ConvertTo-SecureString -String "abcd" -Force -AsPlainText)
$pfxBytes = [System.IO.File]::ReadAllBytes("Certificate.pfx")
$base64Cert = [System.Convert]::ToBase64String($pfxBytes)And added a unit test. |
X509SecurityKey and JsonWebKeyConverter.ConvertFromX509SecurityKey
|
I updated the unit tests not to use the self-signed certificate generated by me but an existing EC key + The parameter Otherwise, this PR is ready to be reviewed. |
|
@jennyf19 marked as 8. |
Fixes #1943.
Fixes #2217.