Skip to content

Instantly share code, notes, and snippets.

@richlander
Last active March 14, 2024 23:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richlander/27c03db34b3f06fd044c611562def589 to your computer and use it in GitHub Desktop.
Save richlander/27c03db34b3f06fd044c611562def589 to your computer and use it in GitHub Desktop.
SSL Challenges on Ubuntu 22.04

Unexpected SSL/TLS behavior

Are the .NET packages missing a ca-certificates dependency?

$ docker run --rm -it ubuntu:jammy
root@708727f57f49:/# apt update
root@708727f57f49:/# apt install -y dotnet6
root@708727f57f49:/# dotnet --version
6.0.127
root@708727f57f49:/# ls -l $(which dotnet) 
lrwxrwxrwx 1 root root 20 Feb  9 05:10 /usr/bin/dotnet -> ../lib/dotnet/dotnet
root@708727f57f49:/# dotnet new console -o app6
root@708727f57f49:/# dotnet run --project app6/app6.csproj 
Hello, World!
root@708727f57f49:/# echo Console.WriteLine\(\$\"Hello \{System.Runtime.InteropServices.RuntimeInformation.OSDescription\} from \{System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription\}\"\)\; > app6/Program.cs
root@708727f57f49:/# dotnet run --project app6/app6.csproj 
Hello Linux 6.5.0-25-generic #25-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb  7 14:58:39 UTC 2024 from .NET 6.0.27
root@708727f57f49:/# apt install -y dotnet7
root@708727f57f49:/# dotnet --version        
7.0.117
root@708727f57f49:/# dotnet new console -o app7
root@708727f57f49:/# dotnet run --project app7/app7.csproj 
Hello, World!
root@708727f57f49:/# echo Console.WriteLine\(\$\"Hello \{System.Runtime.InteropServices.RuntimeInformation.OSDescription\} from \{System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription\}\"\)\; > app7/Program.cs
root@708727f57f49:/# dotnet run --project app6/app6.csproj 
/app6/app6.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.
/app6/app6.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.
/app6/app6.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.

The build failed. Fix the build errors and run again.
root@708727f57f49:/# apt install -y ca-certificates
root@708727f57f49:/# dotnet run --project app6/app6.csproj 
Hello Linux 6.5.0-25-generic #25-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb  7 14:58:39 UTC 2024 from .NET 6.0.27
root@708727f57f49:/# dotnet run --project app7/app7.csproj 
Hello Linux 6.5.0-25-generic #25-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb  7 14:58:39 UTC 2024 from .NET 7.0.17
root@708727f57f49:/# apt install -y dotnet8
root@708727f57f49:/# dotnet --version
8.0.103
root@708727f57f49:/# dotnet new console -o app8
root@708727f57f49:/# dotnet run --project app8/app8.csproj 
Hello, World!
root@708727f57f49:/# dotnet run --project app6/app6.csproj 
Hello Linux 6.5.0-25-generic #25-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb  7 14:58:39 UTC 2024 from .NET 6.0.27
root@708727f57f49:/# dotnet run --project app7/app7.csproj 
Hello Linux 6.5.0-25-generic #25-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb  7 14:58:39 UTC 2024 from .NET 7.0.17
root@708727f57f49:/# dotnet run --project app8/app8.csproj 
Hello Ubuntu 22.04.4 LTS from .NET 8.0.3

Handy C#

Console.WriteLine($"Hello {System.Runtime.InteropServices.RuntimeInformation.OSDescription} from {System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription}");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment