runtime: HTTPS requests fail on Ubuntu 24.04 Noble ARM32 due to bundled certs "NotTimeValid" error

Update: A final resolution to this issue has been posted at https://github.com/dotnet/core/discussions/9285.

Description

HTTPS requests from .NET are failing on Ubuntu 24.04 Noble on ARM32 due to bundled certs “NotTimeValid” errors.

I believe this may be because 24.04 has migrated to 64-bit time. The OpenSSL package has changed from libssl3 to libssl3t64.

Reproduction Steps

  1. dotnet new console
  2. dotnet add package System.Text.Json
  3. .NET will try to restore the package from NuGet.org and fail with the error under “Actual behavior” below.

I created this repro Dockerfile. It may or may not work since I had issues with it on my AMD64 dev machine. No easy way for me to test this currently outside of our official .NET Container image builds. With some trial and error you can probably get the issue to repro on a real arm32 machine using Docker. https://gist.github.com/lbussell/52e0ac904108d238d0e511f8b6ec89e1

Expected behavior

The .NET CLI should successfully access NuGet.org.

Actual behavior

From our PR validation in .NET Docker: https://dev.azure.com/dnceng-public/public/_build/results?buildId=652911&view=logs&j=7bc65791-3246-5ca2-874f-59d2e579cf6b&t=08651ed6-ba3f-5f8a-52df-50083ac157c2&l=942

 #10 2.407 info : X.509 certificate chain validation will use the fallback certificate bundle at '/usr/share/dotnet/sdk/8.0.204/trustedroots/codesignctl.pem'.
 #10 2.491 info : X.509 certificate chain validation will use the fallback certificate bundle at '/usr/share/dotnet/sdk/8.0.204/trustedroots/timestampctl.pem'.
 #10 2.494 info : Adding PackageReference for package 'foo' into project '/source/app/app.csproj'.
 #10 8.602 error: Unable to load the service index for source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json.
 #10 8.602 error:   The SSL connection could not be established, see inner exception.
 #10 8.602 error:   The remote certificate is invalid because of errors in the certificate chain: NotTimeValid

Regression?

No response

Known Workarounds

No response

Configuration

  • .NET Runtime: 8.0.4 and 9.0.0-preview.4.24218.7
  • OS: Ubuntu 24.04 “Noble”
  • Arch: ARM
  • Do you know whether it is specific to that configuration? Yes it is specific to this config. Likely affects older .NET versions as well.

Other information

Discovered in https://github.com/dotnet/dotnet-docker/pull/5241/

Known build error template

Build Information

Build: https://dev.azure.com/dnceng-public/public/_build/results?buildId=674655&view=results Build error leg or test failing: Pull request:

Error Message

Fill the error message using step by step known issues guidance.

{
  "ErrorMessage": ["arm32v7", "The remote certificate is invalid because of errors in the certificate chain: NotTimeValid"],
  "ErrorPattern": "",
  "BuildRetry": false,
  "ExcludeConsoleLog": false
}

Known issue validation

Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=674655 Error message validated: [arm32v7 The remote certificate is invalid because of errors in the certificate chain: NotTimeValid] Result validation: ✅ Known issue matched with the provided build. Validation performed at: 5/16/2024 3:23:33 PM UTC

Report

Build Definition Test Pull Request
674655 dotnet/runtime System.Net.WebSockets.Client.Tests.ArraySegmentSendReceiveTest.ReceiveAsync_MultipleOutstandingReceiveOperations_Throws

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
0 0 1

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 44 (41 by maintainers)

Commits related to this issue

Most upvoted comments

Why isn’t this a problem for Alpine Arm32 if it already has this change? Did they do something special?

I am not sure about servicing.

Clearly, Arm32 has applicability to more than the Debian ecosystem, however, I continue to come back to Raspberry Pi OS being Debian based. Debian 13 will likely ship (with this change) around .NET 10 RC1 (based on past patterns). I also expect a ton of Raspberry Pi deployments are still on Bullseye (Bookworm is < 12 months old) and some of those will be quite happy using .NET 8. In fact (since I haven’t been active with IOT lately), all of my Pi boxes still have Bullseye.

I propose:

  • “Do no harm” with .NET 8 (unless we start to get a lot of customer feedback). Drop support for Ubuntu 24.04 Arm32 for all existing releases.
  • Switch .NET 9+ to target Ubuntu 22.04 for Arm32
  • Push the idea that .NET 8 + Bullseye/Bookworm and .NET 10 + Trixie are the correct LTS pairings for Debian Arm32.
  • Note: Raspberry Pi OS lags Debian by at least 6 months, AFAICT.
  • Document the above.
  • Move on with life.

I want to fix .NET 8 now, but don’t think that it is the right choice for compat or the right prioritization for our efforts.

Context: https://wiki.debian.org/DebianTrixie

@krwq @Ellerbach @joperezr @cjdcordeiro @mirespace

Oh, of course. We have a separate build for Alpine! It all makes sense now.

Looks like we backported that change to servicing. However, I think the calculus on glibc vs musl is not the same.

@vcsjones is correct that there is no such build available. We have never discussed Arm32 with Canonical. Our shared focus has been entirely on 64-bit. It took quite a lot of effort to get to where we are with 24.04 without a lot of extra runway available so I’m glad that there were no additional distractions.

This is somewhat related: https://discourse.ubuntu.com/t/noble-numbat-release-notes/39890#no-32-bit-armhf-images-96

It should be possible to fix both of these calls by backporting https://github.com/dotnet/runtime/pull/100461 that @filipnavara suggested above. It is a hack that depends on Arm ABI details, but anything else would be a hack too - just more complicated one.

You’re referring to: https://github.com/dotnet/runtime/issues/101444#issuecomment-2075946432. This is for the call to X509_VERIFY_PARAM_set_time which takes time_t as an argument.

X509_cmp_time accepts time_t as a pointer, which is probably also ok because the arm32 builds are little endian.

Why isn’t this a problem for Alpine Arm32 if it already has this change? Did they do something special?

The same shard happened between Alpine 3.12 and Alpine 3.13: https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.13.0 https://musl.libc.org/time64.html . https://github.com/dotnet/runtime/pull/51099 is PR where we reacted to it.

The proposed plan LGTM!

https://devblogs.microsoft.com/dotnet/whats-new-for-dotnet-in-ubuntu-2404/ says that .NET 8 is now included in Ubuntu 24.04… presumably that has a .NET built specifically for that OS, which would mean on arm32 it had 64-bit time_t. So .NET 8 may actually be a solved problem (and we just say the portable build isn’t supported on arm32 24.04, that people have to use Canonical’s build).

I do not see an ARM32 architecture for the Noble package feed. Only AMD64, ARM64, and S390x. https://packages.ubuntu.com/noble/dotnet-runtime-8.0

It does not look like there is a non-portable build of ARM32 in any of the package feeds.

https://devblogs.microsoft.com/dotnet/whats-new-for-dotnet-in-ubuntu-2404/ says that .NET 8 is now included in Ubuntu 24.04… presumably that has a .NET built specifically for that OS, which would mean on arm32 it had 64-bit time_t. So .NET 8 may actually be a solved problem (and we just say the portable build isn’t supported on arm32 24.04, that people have to use Canonical’s build).

Target Ubuntu 22.04 (or whichever Ubuntu has that commit in it for libc) for Arm32

Yes, this definitely sounds like the right option for .NET 9+. I am not sure about servicing.

It turns out that it would not be that simple. The old glibc from Ubuntu 16 that we build official portable builds against does not have support for 64-bit time_t. The 64-bit time_t support was added to glibc in 2021.

OH in the team room: “little endian fixes all problems”.

Besides the already mentioned X509_VERIFY_PARAM_set_time there is: X509_cmp_time. I didn’t find others.

It should be possible to fix both of these calls by backporting https://github.com/dotnet/runtime/pull/100461 that @filipnavara suggested above. It is a hack that depends on Arm ABI details, but anything else would be a hack too - just more complicated one.

I’m happy to be shown what I’m missing, though.

There’s not a single stat_t structure definition. There are multiple. For example, there’s __stat64_t64 and stat64. Likewise, there’s __fstat64_time64 and __fstat64 (https://github.com/bminor/glibc/blob/41903cb6f460d62ba6dd2f4883116e2a624ee6f8/sysdeps/unix/sysv/linux/fstat64.c).

Then the header magic is driven by __TIMESIZE (platform “default” time_t size; which should presumably still be 32 on ARM32), _TIME_BITS (what the user wants to compile against, which could be time_t == __time64_t or time_t == __time_t), and __USE_TIME64_REDIRECTS (set automatically based on the first two defines).

Glibc builds support both 32-bit and 64-bit time_t users simultaneously. A user decides at compile time what time representation it has (_TIME_BITS=64). If that user exposes time_t in their API (like OpenSSLX509_VERIFY_PARAM_set_time) then its users (like .NET) must be using the same _TIME_BITS or there is an ABI mismatch.

Another answer, of course, could be that we don’t support the portable build on Linux arm32-with-64-bit-time… but that’s a business decision vs a technical one, so less interesting to discuss (and not our decision to make).

I don’t think the problem is the (ARM32) ABI per-se but the fact whether time_t is defined as 64-bit (__TIMESIZE == 64 / _TIME_BITS == 64) when compiling the OpenSSL or not, and whether that matches the time_t as defined when compiling the native shim. Even if it’s passed by value, the non-matching definition would occupy a different number of registers.

Effectively, if the system libraries start to use a different time_t definition on various platforms we are screwed. That said, I don’t think it’s the case for most system APIs. IIRC for glibc there’s an exported localtime and localtime64 and _TIME_BITS merely controls which one is used through C defines (similar for other APIs). If OpenSSL exports a single symbol that behaves differently then it’s most unfortunate but I don’t think the same problem translates to every time_t API.