Skip to content

Commit

Permalink
Relax PNSE expectation for OSSL providers on Apple platforms (#106804)
Browse files Browse the repository at this point in the history
  • Loading branch information
krwq committed Aug 23, 2024
1 parent 1151ffd commit ad2f140
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,21 @@ public static void EngineNotSupported_ThrowsPlatformNotSupported()
[ConditionalFact(nameof(ProvidersNotSupported))]
public static void ProvidersNotSupported_ThrowsPlatformNotSupported()
{
Assert.Throws<PlatformNotSupportedException>(() => SafeEvpPKeyHandle.OpenKeyFromProvider(Tpm2ProviderName, AnyProviderKeyUri));
try
{
using SafeEvpPKeyHandle key = SafeEvpPKeyHandle.OpenKeyFromProvider("default", NonExistingEngineOrProviderKeyName);
Assert.Fail("We expected an exception to be thrown");
}
catch (PlatformNotSupportedException)
{
// Expected
}
catch (CryptographicException) when (PlatformDetection.IsApplePlatform)
{
// Our tests detect providers using PlatformDetection.IsOpenSsl3 which is always false for Apple platforms.
// Product on the other hand does feature detection and that might end up working
// in which case we should still throw any CryptographicException because the keyUri does not exist.
}
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.OpenSslPresentOnSystem))]
Expand Down

0 comments on commit ad2f140

Please # to comment.