Skip to content

OpenSSL error with Ubuntu 22.04 on Arm32 architecture #66310

Closed

Description

@mthalman

When attempting to run a .NET app that makes an HTTPS connection with the upcoming release of Ubuntu 22.04 on the Arm32 architecture, it results in an OpenSSL error. This issue will block our upcoming support for Ubuntu 22.04 (see dotnet/core#7038).

This only happens in Arm32. Using Arm64 works fine. The easiest way to reproduce this is with a Docker container. But because .NET doesn't work with QEMU, emulation from an x64 machine won't allow you to repro this. You'll need an Arm machine.

I've repro'd this on my Raspberry Pi 4 machine. But it also repros on the .NET Docker team's Jetson build machines which are Arm64.

Repro

  1. Get an Arm machine with Docker installed.

  2. Save the following contents to a file named Dockerfile in an empty directory:

    FROM mcr.microsoft.com/dotnet/sdk:6.0-focal AS build
    
    WORKDIR dotnetapp
    
    # Create a simple project that makes an HTTPS connection
    RUN dotnet new console --no-restore
    RUN echo 'var response = await new System.Net.Http.HttpClient().GetAsync("https://www.microsoft.com"); response.EnsureSuccessStatusCode(); System.Console.WriteLine("Hello World!");' > Program.cs
    
    RUN dotnet publish -c release -o /app -r linux-arm --self-contained /p:PublishSingleFile=true
    
    
    FROM arm32v7/ubuntu:jammy
    
    # Install .NET dependencies
    RUN apt-get update \
        && apt-get install -y --no-install-recommends \
            ca-certificates \
            \
            libc6 \
            libgcc1 \
            libgssapi-krb5-2 \
            libicu67 \
            libssl1.1 \
            libstdc++6 \
            zlib1g \
        && rm -rf /var/lib/apt/lists/*
    
    WORKDIR /app
    COPY --from=build /app .
    ENTRYPOINT ["./dotnetapp"]
  3. Set the current directory to the directory where the Dockerfile is located.

  4. $ docker build -t test

  5. $ docker run --rm test

Expected Results:

Hello World!

Actual Results:

Unhandled exception. System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
 ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception.
 ---> Interop+OpenSsl+SslException: SSL Handshake failed with OpenSSL error - SSL_ERROR_SSL.
 ---> Interop+Crypto+OpenSslCryptographicException: error:0A0000BF:SSL routines::no protocols available
   --- End of inner exception stack trace ---
   at Interop.OpenSsl.DoSslHandshake(SafeSslHandle context, ReadOnlySpan`1 input, Byte[]& sendBuf, Int32& sendCount)
   at System.Net.Security.SslStreamPal.HandshakeInternal(SafeFreeCredentials credential, SafeDeleteSslContext& context, ReadOnlySpan`1 inputBuffer, Byte[]& outputBuffer, SslAuthenticationOptions sslAuthenticationOptions)
   --- End of inner exception stack trace ---
   at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
   at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(HttpRequestMessage request)
   at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at Program.<Main>$(String[] args) in /dotnetapp/Program.cs:line 1
   at Program.<Main>(String[] args)

Activity

  1. ghost added
    untriaged
    on Mar 7, 2022
  2. mthalman commented on Mar 15, 2022

    @mthalman
    MemberAuthor

    @dotnet/ncl, @vcsjones - This issue is time-sensitive in order to have support for the upcoming release of Ubuntu 22.04. I'd like to make sure it's triaged soon.

  3. vcsjones commented on Mar 15, 2022

    @vcsjones
    Member

    @mthalman I can reproduce it using the steps you provided on Graviton2 ARM64 instance.

    I can run openssl s_client -connect www.microsoft.com:443 in the container, I end up negotiating TLSv1.3 TLS_AES_256_GCM_SHA384 with an X25519 key exchange, so I don't think it's a SECLEVEL issue.

    Attached is a tcpdump (opens in Wireshark just fine). dump.bin.zip

    (Learning how to get a tcpdump from a docker container, to a remote VM, to my host was a fun exercise).

  4. vcsjones commented on Mar 15, 2022

    @vcsjones
    Member

    Possibly worth pointing out: this docker image has OpenSSL 3.0.1 on it.

  5. added
    os-linux
    and removed
    untriaged
    on Mar 17, 2022
  6. modified the milestones: Future, 7.0.0 on Mar 17, 2022
  7. karelz commented on Mar 17, 2022

    @karelz
    Member

    @mthalman is there a repro machine (the ARM64 one) we could use? I don't think we have arm32 Raspberry Pis handy for investigation :(

  8. 14 remaining items

  9. am11 commented on Mar 25, 2022

    @am11
    Member

    Release date of Ubuntu 22.04 is April 21, 2022. .NET 5 will reach End of support on May 8, 2022. Do we need backport to .NET 5?

  10. mthalman commented on Mar 25, 2022

    @mthalman
    MemberAuthor

    Release date of Ubuntu 22.04 is April 21, 2022. .NET 5 will reach End of support on May 8, 2022. Do we need backport to .NET 5?

    Probably not. But it'd be worthwhile to post to dotnet/core#7038 indicating what the intention is.

  11. am11 commented on Mar 25, 2022

    @am11
    Member

    I think if there is not going to be another release of .NET 5 in those 17 days, we can skip the backport. Just wanted to point out the short window that we have there.

  12. bartonjs commented on Mar 25, 2022

    @bartonjs
    Member

    3.1 is also not relevant, as we don't support OpenSSL 3 with that release.

  13. wfurt commented on Mar 25, 2022

    @wfurt
    Member

    We also don't need to fix every bug IMHO. This decision should come from ship room.

  14. mthalman commented on Mar 25, 2022

    @mthalman
    MemberAuthor

    We also don't need to fix every bug IMHO. This decision should come from ship room.

    True but this bug effectively makes .NET unusable on this platform for all but the most basic applications.

  15. skytech-cyber commented on Mar 26, 2022

    @skytech-cyber

    amd64 has same issue. "The SSL connection could not be established"

    .NET SDK (reflecting any global.json):
    Version: 6.0.201
    Commit: ef40e6aa06

    Runtime Environment:
    OS Name: ubuntu
    OS Version: 22.04
    OS Platform: Linux
    RID: linux-x64
    Base Path: /usr/share/dotnet/sdk/6.0.201/

  16. rzikm commented on Mar 28, 2022

    @rzikm
    Member

    @skytech-cyber Is the issue on the same callstack and with the same message? I was using OpenSSL 3 locally several times (although on different distro) and have not run into this issue.

  17. ghost added
    in-pr
    on Apr 8, 2022
  18. ghost removed
    in-pr
    on Apr 13, 2022
  19. rzikm commented on Apr 14, 2022

    @rzikm
    Member

    The bug has been fixed in main and in 6.0.5. Backporting to other versions is not needed: .NET 5 is near EOL and .NET 3.1 does not support OpenSSL 3.0.

  20. leopignataro commented on Apr 29, 2022

    @leopignataro

    Dear @bartonjs and @rzikm, you both mentioned .NET Core 3.1 does not support OpenSSL 3.0. What does that mean in terms of the future support (or lack of) for .NET Core Runtime 3.1 on Ubuntu 22.04?

    Thanks!

  21. mthalman commented on Apr 29, 2022

    @mthalman
    MemberAuthor

    Dear @bartonjs and @rzikm, you both mentioned .NET Core 3.1 does not support OpenSSL 3.0. What does that mean in terms of the future support (or lack of) for .NET Core Runtime 3.1 on Ubuntu 22.04?

    See dotnet/core#7038 (comment)

  22. ghost locked as resolved and limited conversation to collaborators on May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-arm32area-System.Net.Securitybugos-linux

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions