Skip to content

Commit 4e3300c

Browse files
authored
fix keyinfo null ref (#3203)
1 parent 35e9c38 commit 4e3300c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Microsoft.IdentityModel.Xml/KeyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private bool Matches(X509SecurityKey key)
165165

166166
private bool Matches(RsaSecurityKey key)
167167
{
168-
if (key == null)
168+
if (key == null || RSAKeyValue == null)
169169
return false;
170170

171171
if (!key.Parameters.Equals(default(RSAParameters)))

test/Microsoft.IdentityModel.Xml.Tests/KeyInfoTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,14 @@ public static TheoryData<KeyInfoTheoryData> KeyInfoMatchesTheoryData
334334
MatchesKey = true,
335335
});
336336

337+
theoryData.Add(new KeyInfoTheoryData("NullRSAKeyValue")
338+
{
339+
ExpectedException = ExpectedException.NoExceptionExpected,
340+
KeyInfo = new KeyInfo(), // This will have null RSAKeyValue
341+
SecurityKey = KeyingMaterial.RsaSecurityKey_2048_Public,
342+
MatchesKey = false,
343+
});
344+
337345
return theoryData;
338346
}
339347
}

0 commit comments

Comments
 (0)