httpClient.SendAsync throws Unspecified GSS failure

1

I am using .NET Core 3.1 Here is a code that I am using:

        CredentialCache credentialCache = new CredentialCache();
        credentialCache.Add(new Uri(URL), "NEGOTIATE", new NetworkCredential(USER, PASSWORD, DOMAIN));

        using (HttpClientHandler handler = new HttpClientHandler())
        {
            handler.Credentials = credentialCache;

            using (HttpClient httpClient = new HttpClient(handler))
            {
                HttpRequestMessage request = new HttpRequestMessage(new HttpMethod("GET"), REQUEST_URL);

                HttpResponseMessage response = httpClient.SendAsync(request).Result;

                Console.Write(response.ToString());
            }
        }

It works corrent on my windows machine but crushes when is launched on linux docker container:

System.AggregateException: One or more errors occurred. (GSSAPI operation failed with error - Unspecified GSS failure. Minor code may provide more information (Cannot find KDC for realm "DOMAIN_NAME").) ---> System.ComponentModel.Win32Exception (0x80090020): GSSAPI operation failed with error - Unspecified GSS failure. Minor code may provide more information(Cannot find KDC for realm "DOMAIN_NAME"). at System.Net.Security.NegotiateStreamPal.AcquireCredentialsHandle(String package, Boolean isServer, NetworkCredential credential) at System.Net.NTAuthentication.Initialize(Boolean isServer, String package, NetworkCredential credential, String spn, ContextFlagsPal requestedContextFlags,ChannelBinding channelBinding) at System.Net.Http.AuthenticationHelper.SendWithNtAuthAsync(HttpRequestMessage request, Uri authUri, ICredentials credentials, Boolean isProxyAuth, HttpConnection connection, HttpConnectionPool connectionPool, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync(HttpConnection connection, HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.AuthenticationHelper.SendWithAuthAsync(HttpRequestMessage request, Uri authUri, ICredentials credentials, Boolean preAuthenticate, Boolean isProxyAuth, Boolean doRequestAuth, HttpConnectionPool pool, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at OurHomeServer.Log.LoggingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) in /src/OurHomeServer/Log/LoggingHandler.cs:line 35 at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)

It works when I use curl request in container's shell.

docker
.net-core
httpclient
asked on Stack Overflow Nov 9, 2020 by walruz

1 Answer

0

I added following line to my Dockerfile

RUN apt install -y mc sudo syslog-ng realmd gss-ntlmssp

and now it works!!

answered on Stack Overflow Nov 16, 2020 by walruz

User contributions licensed under CC BY-SA 3.0