I have a ASP.NET Core 8 Application which is being dockerized and deployed in Openshift.
The problem is that I cant authenticate to an endpoint using NTLM.
From my windows machine i can use it just fine, as expected, considering its both windows.
This is the output of the logged request inside the pod:
Request:
Method: GET
Target:
Request Headers:
Response:
Status Code: ServiceUnavailable
Response Headers:
Cache-Control: no-cache
X-XSS-Protection: 1
Connection: close
Pragma: no-cache
Content-Type: text/html; charset=utf-8
Content-Length: 768
I can call the endpoint manually by using curl with the –ntlm flag inside of the pods terminal. So connectivity should’nt be the problem.
I’ve tried using the standard aspnet:8.0 base image and also an alpine:latest
I’ve tried installing the gss-ntlmssp onto the aspnet base image, cant get it to install tho:
E: The repository 'http://deb.debian.org/debian bookworm InRelease' is not signed.
E: Failed to fetch http://deb.debian.org/debian/dists/bookworm/InRelease 403 Forbidden
I’ve tried installing the krb5-libs when using the alpine base image (gss-ntlmssp isnt available on alpine).
And i’ve also tried setting the UseManagedNtlm
``<ItemGroup>
<RuntimeHostConfiguration Include="System.Net.Security.UseManagedNtlm" Value="true"/>
</ItemGroup>` `
both in the .csproj and in the Program.cs with:
AppContext.SetSwitch("System.Net.Security.UseManagedNtlm", true);
as suggested by the various GitHub threads regarding this topic.
This is my HttpClient:
...
private static HttpClient s_client;
private static void CreateHttpClientWithNtlmAuth(IConfiguration configuration)
{
var aDUser = configuration["SRV_USER"];
var aDPassword = configuration["SRV_PASSWORD"];
HttpClientHandler hand = new HttpClientHandler
{
UseDefaultCredentials = false,
Credentials = new NetworkCredential(aDUser, aDPassword, "<domain>"),
PreAuthenticate = true,
};
s_client = new HttpClient(new LoggingHandler(hand));
}
...
I think that i’ve tried every possbile permutation of requested fixes but cant seem to get it to work. So there must be something I am missing. Appreciate any help.
6
You can try download gss-ntlmssp
in your docker file.
Example: RUN apt-get update && apt-get install -y --no-install-recommends gss-ntlmssp