File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
src/AspNet.Security.OAuth.Apple/Internal Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 12
12
<PackageVersion Include =" Microsoft.NetCore.Analyzers" Version =" 3.0.0" />
13
13
<PackageVersion Include =" Shouldly" Version =" 3.0.2" />
14
14
<PackageVersion Include =" StyleCop.Analyzers" Version =" 1.1.118" />
15
-
16
- <!--
17
- Cannot use later versions (5.5.0+) due to https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/1302.
18
- -->
19
15
<PackageVersion Include =" System.IdentityModel.Tokens.Jwt" Version =" 5.4.0" />
20
16
</ItemGroup >
21
17
Original file line number Diff line number Diff line change @@ -18,6 +18,11 @@ namespace AspNet.Security.OAuth.Apple.Internal
18
18
{
19
19
internal sealed class DefaultAppleClientSecretGenerator : AppleClientSecretGenerator
20
20
{
21
+ private static readonly CryptoProviderFactory CryptoProviderFactory = new CryptoProviderFactory ( )
22
+ {
23
+ CacheSignatureProviders = false ,
24
+ } ;
25
+
21
26
private readonly ISystemClock _clock ;
22
27
private readonly ILogger _logger ;
23
28
private readonly AppleKeyStore _keyStore ;
@@ -110,7 +115,13 @@ private static ECDsa CreateAlgorithm(byte[] keyBlob)
110
115
private static SigningCredentials CreateSigningCredentials ( string keyId , ECDsa algorithm )
111
116
{
112
117
var key = new ECDsaSecurityKey ( algorithm ) { KeyId = keyId } ;
113
- return new SigningCredentials ( key , SecurityAlgorithms . EcdsaSha256Signature ) ;
118
+
119
+ // Use a custom CryptoProviderFactory so that keys are not cached and then disposed of, see below:
120
+ // https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/1302
121
+ return new SigningCredentials ( key , SecurityAlgorithms . EcdsaSha256Signature )
122
+ {
123
+ CryptoProviderFactory = CryptoProviderFactory ,
124
+ } ;
114
125
}
115
126
}
116
127
}
You can’t perform that action at this time.
0 commit comments