Skip to content

.NET 6: Interop.AppleCrypto.GetRandomBytes fails on all iOS Devices #58185

@josephatkuvio

Description

@josephatkuvio

Description

On .NET 6 Preview 7, all calls to Interop.AppleCrypto.GetRandomBytes fail on all current iOS devices with a DllNotFoundException: libcoreclr.so. This call works fine on all iOS Simulator configurations, and all other platforms tested.

In my particular case, this call is occurring within various public authentication libraries, to securely generate random strings for PKCE codes (both IdentityModel and System.Identity.Client). When I rebuild these libraries to use System.Random() instead (which I'm sure breaks compliance), the app runs fine. Not able to tell via the stack trace what the underlying issue might be.

Configuration

.NET 6 Preview 7
MAUI Single Project
Blazor + MAUI.WebView
iOS ARM64 Build
IdentityModel and/or System.Identity.Client Package

Regression?

Unknown, but likely a regression from mono/mono, as these packages work fine in Xamarin builds.

Other information

Relevant stack trace

System.DllNotFoundException: libcoreclr.so 
at Interop.AppleCrypto.GetRandomBytes(Byte*, Inte32) in System.Security.Cryptography.Algorithms.dll
at System.Security.Cryptography.RandomNumberGenerator in System.Security.Cryptography.Algorithms.dll
at IdentityModel.CryptoRandom.CreateRandomKey in IdentityModel.dll

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions