Skip to content

Commit eeab478

Browse files
authored
Fix generic claims not signing (#46)
When calling DoEncode for GenericClaims the expected prefixes length of 0 is stopping the signing and throwing an exception. We can skip the check when expected prefixes length=0.
1 parent 87c4538 commit eeab478

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/NATS.Jwt/NatsJwt.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ private static string DoEncode<T>(JwtHeader jwtHeader, KeyPair keyPair, T claim,
475475

476476
string issuer = keyPair.GetPublicKey();
477477
PrefixByte[] expectedPrefixes = c.ExpectedPrefixes();
478-
if (!expectedPrefixes.Any(p => KeyPair.IsValidPublicKey(p, issuer.AsSpan())))
478+
if (expectedPrefixes.Length > 0 && !expectedPrefixes.Any(p => KeyPair.IsValidPublicKey(p, issuer.AsSpan())))
479479
{
480480
throw new NatsJwtException($"Invalid signing key of '{keyPair.Prefix}': expected one of '{string.Join(",", expectedPrefixes)}'");
481481
}

0 commit comments

Comments
 (0)