.netmacossslapple-silicon.net-9.0

.NET 9 on macOS ARM64: HttpClient fails with CSSM_ModuleLoad() / SSL connection error during unit tests


I'm running .NET 9.0.306 on macOS ARM64 and encountering an issue when running unit tests that call an external HTTPS API via HttpClient.

Note - Cookies disabled because problem first appeared as a type init error with CookiesContainer I think.

Minimal reproduction pattern:

HttpClient httpClient =
    new(new SocketsHttpHandler()
    {
        PooledConnectionLifetime = TimeSpan.FromMinutes(1),
        UseCookies = false  // Disable CookieContainer to avoid macOS .NET 9 ARM64 CSSM initialization bug
    });

// Later
response = await httpClient.PostAsJsonAsync(
    "https://api.openai.com/v1/chat/completions", 
    requestDto, 
    jsonOptions, 
    cancellationToken);

When I run my tests:

This is logged first.

CSSM_ModuleLoad(): One or more parameters passed to a function were not valid.

Then an exception later:

The SSL connection could not be established, see inner exception.

Happens only on Apple Silicon macOS 15.7.1 - not tested on Windows, works on live Linux in GCP.

Questions:

Why does this happen specifically on macOS ARM64 with .NET 9? Worked under .NET 7, skipped 8.

Is this a known bug in .NET 9?

LLMs reckon this is frictionful area for .NET/OS interop.


Solution

  • It is immediately working today. I noticed "Auto-run in Sandbox" in Cursor had appeared recently.

    Sandbox is currently available on macOS only. Linux support is coming soon. Windows users can use WSL or devcontainers for sandboxed command execution.

    By default, Agent runs terminal commands in a restricted environment that blocks unauthorized file access and network activity

    It seems, as often happens, two changes (one obvious and large, and the other silent and unnoticed) coincide to cause grief.