Skip to content

Commit 0e9d775

Browse files
committed
Port fix
1 parent c3295d5 commit 0e9d775

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/SignalR/common/Http.Connections/test/HttpConnectionDispatcherTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using System.Net.Http;
1414
using System.Net.WebSockets;
1515
using System.Security.Claims;
16+
using System.Security.Cryptography;
1617
using System.Security.Principal;
1718
using System.Text;
1819
using 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 =>

src/SignalR/samples/JwtSample/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace JwtSample;
1111

1212
public 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)

src/SignalR/server/SignalR/test/Startup.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.IdentityModel.Tokens.Jwt;
66
using System.IO;
77
using System.Security.Claims;
8+
using System.Security.Cryptography;
89
using System.Threading.Tasks;
910
using Microsoft.AspNetCore.Authentication.JwtBearer;
1011
using Microsoft.AspNetCore.Authorization;
@@ -18,7 +19,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests;
1819

1920
public 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)

0 commit comments

Comments
 (0)