File tree Expand file tree Collapse file tree 3 files changed +6
-4
lines changed
common/Http.Connections/test Expand file tree Collapse file tree 3 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 1313using System . Net . Http ;
1414using System . Net . WebSockets ;
1515using System . Security . Claims ;
16+ using System . Security . Cryptography ;
1617using System . Security . Principal ;
1718using System . Text ;
1819using System . Threading ;
@@ -2818,7 +2819,7 @@ public async Task ConnectionClosedRequestedTriggeredOnAuthExpiration()
28182819 [ InlineData ( HttpTransportType . WebSockets ) ]
28192820 public async Task AuthenticationExpirationSetOnAuthenticatedConnectionWithJWT ( HttpTransportType transportType )
28202821 {
2821- SymmetricSecurityKey SecurityKey = new SymmetricSecurityKey ( Guid . NewGuid ( ) . ToByteArray ( ) ) ;
2822+ SymmetricSecurityKey SecurityKey = new SymmetricSecurityKey ( SHA256 . HashData ( Guid . NewGuid ( ) . ToByteArray ( ) ) ) ;
28222823 JwtSecurityTokenHandler JwtTokenHandler = new JwtSecurityTokenHandler ( ) ;
28232824
28242825 using var host = CreateHost ( services =>
@@ -2980,7 +2981,7 @@ public async Task AuthenticationExpirationSetOnAuthenticatedConnectionWithCookie
29802981 [ InlineData ( HttpTransportType . WebSockets ) ]
29812982 public async Task AuthenticationExpirationUsesCorrectScheme ( HttpTransportType transportType )
29822983 {
2983- var SecurityKey = new SymmetricSecurityKey ( Guid . NewGuid ( ) . ToByteArray ( ) ) ;
2984+ var SecurityKey = new SymmetricSecurityKey ( SHA256 . HashData ( Guid . NewGuid ( ) . ToByteArray ( ) ) ) ;
29842985 var JwtTokenHandler = new JwtSecurityTokenHandler ( ) ;
29852986
29862987 using var host = CreateHost ( services =>
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ namespace JwtSample;
1111
1212public class Startup
1313{
14- private readonly SymmetricSecurityKey SecurityKey = new SymmetricSecurityKey ( RandomNumberGenerator . GetBytes ( 16 ) ) ;
14+ private readonly SymmetricSecurityKey SecurityKey = new SymmetricSecurityKey ( RandomNumberGenerator . GetBytes ( 32 ) ) ;
1515 private readonly JwtSecurityTokenHandler JwtTokenHandler = new JwtSecurityTokenHandler ( ) ;
1616
1717 public void ConfigureServices ( IServiceCollection services )
Original file line number Diff line number Diff line change 55using System . IdentityModel . Tokens . Jwt ;
66using System . IO ;
77using System . Security . Claims ;
8+ using System . Security . Cryptography ;
89using System . Threading . Tasks ;
910using Microsoft . AspNetCore . Authentication . JwtBearer ;
1011using Microsoft . AspNetCore . Authorization ;
@@ -18,7 +19,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests;
1819
1920public class Startup
2021{
21- private readonly SymmetricSecurityKey SecurityKey = new SymmetricSecurityKey ( Guid . NewGuid ( ) . ToByteArray ( ) ) ;
22+ private readonly SymmetricSecurityKey SecurityKey = new SymmetricSecurityKey ( SHA256 . HashData ( Guid . NewGuid ( ) . ToByteArray ( ) ) ) ;
2223 private readonly JwtSecurityTokenHandler JwtTokenHandler = new JwtSecurityTokenHandler ( ) ;
2324
2425 public void ConfigureServices ( IServiceCollection services )
You can’t perform that action at this time.
0 commit comments