Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"The SSL connection could not be established" when publishing despite docker login success #338

Closed
QuantumToasted opened this issue Feb 10, 2023 · 17 comments

Comments

@QuantumToasted
Copy link

QuantumToasted commented Feb 10, 2023

I am attempting to publish my images to a local (LAN, not same device) registry during build via the following publish command:

dotnet publish --os linux --arch x64 -c Release /t:PublishContainer -p:ContainerImageName=linus -p:ContainerRegistry=portainer.local:32768

However, the following error occurs during building (full build output below):

Output
MSBuild version 17.4.1+9a89d02ff for .NET
  Determining projects to restore...
  Restored D:\Code\Linus\Linus.csproj (in 239 ms).
  Linus -> D:\Code\Linus\bin\Release\net7.0\linux-x64\Linus.dll
  Linus -> D:\Code\Linus\bin\Release\net7.0\linux-x64\publish\
  Building image 'linus' with tags 1.0.0 on top of base image mcr.microsoft.com/dotnet/runtime:7.0
  Uploading layer sha256:bb263680fed18eecdc67f885094df6f589bafc19004839d7fdf141df236a61aa to portainer.local
  Uploading layer sha256:dff5dc947f3862f82b1f73d4ecbd58c35db35a33631d54604377e4616759b6e9 to portainer.local
  Uploading layer sha256:753f39de0335d8570d9f310cab6547650ac744d62d1e5cbd6e716a1b9e8191c4 to portainer.local
  Uploading layer sha256:c671073c7a89f080aefc598baca97a4b232d1f597738eae7888033638a8ee31e to portainer.local
  Uploading layer sha256:ed8da48a765e595a4492b50b66824970421bb768d7744a38ab9af815fc3ca1f1 to portainer.local
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error : Failed to push to the output registry: System.AggregateException: One or more erro
rs occurred. (The SSL connection could not be established, see inner exception.) [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :  ---> System.Net.Http.HttpRequestException: The SSL connection could not be establ
ished, see inner exception. [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :  ---> System.Security.Authentication.AuthenticationException: Cannot determine the
 frame size or a corrupted frame was received. [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at System.Net.Security.SslStream.GetFrameSize(ReadOnlySpan`1 buffer) [D:\Code\L
inus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at System.Net.Security.SslStream.EnsureFullTlsFrameAsync[TIOAdapter](Cancellati
onToken cancellationToken) [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMa
chineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token) [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at System.Net.Security.SslStream.ReceiveBlobAsync[TIOAdapter](CancellationToken
 cancellationToken) [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](Boolean r
eceiveFirst, Byte[] reAuthenticationData, CancellationToken cancellationToken) [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthentic
ationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken) [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    --- End of inner exception stack trace --- [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthentic
ationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken) [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request,
Boolean async, CancellationToken cancellationToken) [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMe
ssage request, Boolean async, CancellationToken cancellationToken) [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(QueueItem queueI
tem) [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancel
lationAsync(CancellationToken cancellationToken) [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at System.Net.Http.HttpConnectionPool.HttpConnectionWaiter`1.WaitForConnectionA
sync(Boolean async, CancellationToken requestCancellationToken) [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(Htt
pRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolea
n async, CancellationToken cancellationToken) [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at Microsoft.NET.Build.Containers.AuthHandshakeMessageHandler.SendAsync(HttpReq
uestMessage request, CancellationToken cancellationToken) in D:\a\_work\1\s\Microsoft.NET.Build.Containers\AuthHandshakeMessageHandler.cs:line 173 [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage reques
t, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at Microsoft.NET.Build.Containers.Registry.BlobAlreadyUploaded(String name, Str
ing digest, HttpClient client) in D:\a\_work\1\s\Microsoft.NET.Build.Containers\Registry.cs:line 381 [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at Microsoft.NET.Build.Containers.Registry.<>c__DisplayClass40_0.<<Push>b__0>d.
MoveNext() in D:\a\_work\1\s\Microsoft.NET.Build.Containers\Registry.cs:line 431 [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error : --- End of stack trace from previous location --- [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at Microsoft.NET.Build.Containers.Registry.Push(Image x, String name, String ta
g, String baseName, Action`1 logProgressMessage) in D:\a\_work\1\s\Microsoft.NET.Build.Containers\Registry.cs:line 460 [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    --- End of inner exception stack trace --- [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledEx
ceptions) [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToke
n cancellationToken) [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at System.Threading.Tasks.Task.Wait() [D:\Code\Linus\Linus.csproj]
C:\Users\omitted\.nuget\packages\microsoft.net.build.containers\0.3.2\build\Microsoft.NET.Build.Containers.targets(114,9): error :    at Microsoft.NET.Build.Containers.Tasks.CreateNewImage.Execute() in D:\a\_work\
1\s\Microsoft.NET.Build.Containers\CreateNewImage.cs:line 149 [D:\Code\Linus\Linus.csproj]

Logging into this registry via docker login on the same machine works fine, and does not change the output whether it's run before or after the failed publish. I did have to add it as an insecure registry. (However, I don't have any local images to try pushing to see if it's an issue with the registry, sorry 😢)

Is this an issue with this tool, the registry, or something else? If it perhaps could be the cause, the same local domain (portainer.local) happens to have a self-signed cert for the portainer container itself.

@QuantumToasted QuantumToasted changed the title "The SSL connection could not be established" despite docker login success "The SSL connection could not be established" when publishing despite docker login success Feb 10, 2023
@baronfel
Copy link
Member

baronfel commented Feb 12, 2023

@QuantumToasted I think this is because we have an assumption that any registry not explicitly on localhost requires TLS - this method enforces this invariant everywhere in our codebase. It seems that for this case this invariant it's true. I expect that setting up and trusting a TLS cert for this portainer instance is out of the question? If so, we should have some kind of way to signal that the registry doesn't require TLS.

@QuantumToasted
Copy link
Author

QuantumToasted commented Feb 14, 2023

It seems that for this case this invariant it's true. I expect that setting up and trusting a TLS cert for this portainer instance is out of the question?

Not necessarily? My Portainer instance (or specifically, the registry) is intended to be local-only and not accessible outside of the LAN - my personal workflow was doing development on my desktop PC, and then docker build/docker pushing everything to my private registry hosted on Portainer, so I didn't have to pay for or utilize public registries. As such, I didn't really see a reason to require TLS in this case as I would not be communicating with the "outside" to push images to the registry.

However I will concede I am a total newbie when it comes to Docker and other containerization systems, as far as "best practices" go - I might just be doing something totally backwards, explaining why I am having this issue in the first place? If it would make more sense for me, a single developer, to make my workflow conform to a "standard" that most people follow, than to suggest a tool change its functionality to conform to my weird workflow, then that's fine as well.

@wazzamatazz
Copy link

Personally, I'd like to have an option of pushing to non-localhost non-TLS registries. I appreciate that it's absolutely not good practice in any sort of professional environment but if I'm just playing around at home and want to push to a registry on a local Raspberry PI I think that should be possible without having to configure TLS, especially because I can configure Docker Desktop to allow that at my own risk.

@giammin
Copy link

giammin commented May 9, 2023

i'm experiencing the same behavior trying to publish an image to a docker engine running inside wsl2.

@ripebananas
Copy link

Bump. I have a similar The SSL connection could not be established error when trying to pull the base image (i.e. the ContainerBaseImage in the csproj file) from a non-TLS local registry. Would be nice to have a similar setting to docker's insecure-registries option.

@mdsitton
Copy link

mdsitton commented Jul 7, 2023

I am also hitting this as well, having this as an option is absolutely needed.

@mdsitton
Copy link

mdsitton commented Jul 7, 2023

Additionally self-signed certificates do not work just as confirmation

Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013: Failed to push to the output registry: System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:  ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:    at System.Net.Security.SslStream.SendAuthResetSignal(ProtocolToken message, ExceptionDispatchInfo exception) [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:    at System.Net.Security.SslStream.CompleteHandshake(SslAuthenticationOptions sslAuthenticationOptions) [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:    at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](Boolean receiveFirst, Byte[] reAuthenticationData, CancellationToken cancellationToken) [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:    at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken) [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:    --- End of inner exception stack trace --- [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:    at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken) [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:    at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:    at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:    at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(QueueItem queueItem) [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:    at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken cancellationToken) [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:    at System.Net.Http.HttpConnectionPool.HttpConnectionWaiter`1.WaitForConnectionAsync(Boolean async, CancellationToken requestCancellationToken) [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:    at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:    at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:    at Microsoft.NET.Build.Containers.AuthHandshakeMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) in /_/src/Containers/Microsoft.NET.Build.Containers/AuthHandshakeMessageHandler.cs:line 175 [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:    at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:    at Microsoft.NET.Build.Containers.Registry.BlobAlreadyUploadedAsync(String repository, String digest, HttpClient client, CancellationToken cancellationToken) in /_/src/Containers/Microsoft.NET.Build.Containers/Registry.cs:line 497 [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:    at Microsoft.NET.Build.Containers.Registry.<>c__DisplayClass51_0.<<PushAsync>b__0>d.MoveNext() in /_/src/Containers/Microsoft.NET.Build.Containers/Registry.cs:line 546 [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013: --- End of stack trace from previous location --- [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:    at Microsoft.NET.Build.Containers.Registry.PushAsync(BuiltImage builtImage, ImageReference source, ImageReference destination, Action`1 logProgressMessage, CancellationToken cancellationToken) in /_/src/Containers/Microsoft.NET.Build.Containers/Registry.cs:line 575 [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: /home/coda/.nuget/packages/microsoft.net.build.containers/7.0.305/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1013:    at Microsoft.NET.Build.Containers.Tasks.CreateNewImage.ExecuteAsync(CancellationToken cancellationToken) in /_/src/Containers/Microsoft.NET.Build.Containers/Tasks/CreateNewImage.cs:line 127 [/home/coda/actions-runner/_work/analytics-server/analytics-server/ApiServer/ApiServer.csproj]
Error: Process completed with exit code 1.

@mdsitton
Copy link

mdsitton commented Jul 7, 2023

@baronfel Any thoughts on at least implementing a way to have self-signed certs for this?

@baronfel
Copy link
Member

baronfel commented Jul 7, 2023

@tmds you have some background here - you mentioned that it may be difficult to trust self-signed certs on Linux. do you have any docs that might clarify the situation?

@tmds
Copy link
Member

tmds commented Jul 10, 2023

you have some background here - you mentioned that it may be difficult to trust self-signed certs on Linux. do you have any docs that might clarify the situation?

If I recall correctly, adding a self-signed cert to the system certificate store on Fedora does not cause .NET applications to trust an HTTPS server using that certificate.

I did have to add it as an insecure registry.

Both podman and docker allow to configure certain registries as insecure. podman allows to also configure it on a per-command basis using the --tls-verify=false flag.

The SDK could pick up such a configuration setting through an environment variable, for example: SDK_CONTAINER_INSECURE_REGISTRIES which can be set by the user to a semi-colon separated list of registry names.

@rido-min
Copy link
Member

rido-min commented Nov 1, 2023

same issue using k3d registry

@baronfel
Copy link
Member

baronfel commented Nov 1, 2023

It appears that the .NET Runtime respects some OpenSSL certificate store overrides that use environment variables: dotnet/runtime#23666 (comment)

Would this be acceptable here?

@Devqon
Copy link

Devqon commented Nov 3, 2023

We also host a private docker registry inside our private network without TLS. In my eyes it would be logical that the dotnet publish command should respect the insecure-registries option from the docker daemon.

As a workaround we now forward the port on our dev-machines and (self-hosted) build agents to the registry's ip address to make use (misuse?) of the localhost exception from this TLS rule:

netsh interface portproxy add v4tov4 listenport=$RegistryPort listenaddress=127.0.0.1 connectaddress=$DockerRegistryIp connectport=$RegistryPort

@baronfel
Copy link
Member

baronfel commented Nov 3, 2023

But yes - consider a new env var SDK_CONTAINER_INSECURE_REGISTRIES whose values are a semicolon-delimited list of registries (which can be domain + port) as approved and up for grabs.

@richlander
Copy link
Member

I just ran into this. I launched the registry image and am wanting to push it to it w/o TLS.

My experience:

$ docker run -d -p 5000:5000 registry
$ docker run --add-host=host.docker.internal:host-gateway --rm -it -v $(pwd):/source -w /source mcr.microsoft.com/dotnet/nightly/sdk:8.0-jammy-aot dotnet publish -p PublishProfile=DefaultContainer -p ContainerRepository=hello-native-api -p ContainerRegistry=host.docker.internal:5000
MSBuild version 17.8.3+195e7f5a3 for .NET
  Determining projects to restore...
  Restored /source/hello-native-api.csproj (in 3.86 sec).
/usr/share/dotnet/sdk/8.0.100-rtm.23523.2/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(311,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [/source/hello-native-api.csproj]
  hello-native-api -> /source/bin/Release/net8.0/linux-x64/hello-native-api.dll
  hello-native-api -> /source/bin/Release/net8.0/linux-x64/publish/
  Building image 'hello-native-api' with tags 'latest' on top of base image 'mcr.microsoft.com/dotnet/nightly/runtime-deps:8.0-jammy-chiseled-aot'.
  Uploading layer 'sha256:2cf7030f21c01c0712d16119d6d7109c7cef1e5d5c24a006f771bbfdb414a865' to 'host.docker.internal:5000'.
  Uploading layer 'sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1' to 'host.docker.internal:5000'.
  Uploading layer 'sha256:381ac59dfb47a15f47a006c1e4ed24b27574b8159fd282a0d53bf3491f02d4de' to 'host.docker.internal:5000'.
/usr/share/dotnet/sdk/8.0.100-rtm.23523.2/Containers/build/Microsoft.NET.Build.Containers.targets(202,5): error CONTAINER1013: Failed to push to the output registry: The SSL connection could not be established, see inner exception. [/source/hello-native-api.csproj]

Same thing?

@beardboy
Copy link

Would also like the ability to publish to local docker registry without TLS.

@baronfel
Copy link
Member

baronfel commented Aug 8, 2024

Going to close this out, as the upcoming 8.0.400 and .NET 9.0.100-preview.7 releases cover this request!

@baronfel baronfel closed this as completed Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests