Skip to content
Prev Previous commit
Next Next commit
Fix
  • Loading branch information
joegoldman2 committed Jul 2, 2024
commit 3141e61f094590a1441f61c93030b0b3d71d8aac
4 changes: 4 additions & 0 deletions src/Microsoft.IdentityModel.Tokens/JsonWebKeyConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,23 @@ public static JsonWebKey ConvertFromX509SecurityKey(X509SecurityKey key, bool re
{
return ConvertFromRSASecurityKey(new RsaSecurityKey(rsaPrivateKey) { KeyId = key.KeyId });
}
#if NET472 || NETSTANDARD2_0 || NET6_0_OR_GREATER
else if (key.PrivateKey is ECDsa ecdsaPrivateKey)
{
return ConvertFromECDsaSecurityKey(new ECDsaSecurityKey(ecdsaPrivateKey) { KeyId = key.KeyId });
}
#endif
}
else if (key.PublicKey is RSA rsaPublicKey)
{
return ConvertFromRSASecurityKey(new RsaSecurityKey(rsaPublicKey) { KeyId = key.KeyId });
}
#if NET472 || NETSTANDARD2_0 || NET6_0_OR_GREATER
else if (key.PublicKey is ECDsa ecdsaPublicKey)
{
return ConvertFromECDsaSecurityKey(new ECDsaSecurityKey(ecdsaPublicKey) { KeyId = key.KeyId });
}
#endif

throw LogHelper.LogExceptionMessage(new NotSupportedException(LogHelper.FormatInvariant(LogMessages.IDX10674, LogHelper.MarkAsNonPII(key.GetType().FullName))));
}
Expand Down