Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion PluginVersion.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
:
SmartCertificateKeyProviderPlugin:2.0.1
SmartCertificateKeyProviderPlugin:2.0.2
:

20 changes: 11 additions & 9 deletions Source/SmartCertificateKeyProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SmartCertificateKeyProviderPlugin
namespace SmartCertificateKeyProviderPlugin
{
using System;
using System.Linq;
Expand Down Expand Up @@ -109,13 +109,15 @@ public override byte[] GetKey(KeyProviderQueryContext keyProviderQueryContext)
{
try
{
if (certificate.PrivateKey is RSA rsa)
{
CertificateCache.StoreCachedValue(keyProviderQueryContext.DatabasePath, certificate.Thumbprint);

// Using HashAlgorithmName.SHA1 for backward compatibility
return rsa.SignData(DataToSign, HashAlgorithmName.SHA1, RSASignaturePadding.Pkcs1); // DO NOT CHANGE THIS!!!!;
}
using (RSA rsa = certificate.GetRSAPrivateKey())
{
if (rsa != null)
{
CertificateCache.StoreCachedValue(keyProviderQueryContext.DatabasePath, certificate.Thumbprint);

return rsa.SignData(DataToSign, HashAlgorithmName.SHA1, RSASignaturePadding.Pkcs1);
}
}
}
catch (Exception ex)
{
Expand Down Expand Up @@ -156,4 +158,4 @@ private void OnDatabaseOpened(object sender, FileOpenedEventArgs args)

#endregion
}
}
}