Description
Describe the Bug
Using 7.0-jammy
/8.0-jammy
, 8.0-alpine
images (linux-x64
) and manually installing gss-ntlmssp
library does not seem to allow NTLM authentication when using a WCF connected service in a .NET 8 Web API project.
When I converted my project down to 6.0-focal
, it worked. Then I tried to understand if this was a .NET 7+ issue, but I eventually found that the 8.0-bookworm-slim
image worked, so it didn't seem to be a .NET version, but seemed to be more tied to the base image.
In the -jammy
and -alpine
images, the error I would get when connecting to my WCF service was:
MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'NTLM'.
Steps to Reproduce
Dockerfile (that does not work):
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy AS base
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
RUN apt-get update && apt-get install -y \
krb5-user \
libkrb5-dev \
gss-ntlmssp \
&& rm -rf /var/lib/apt/lists/*
USER app
FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["dotnet-ntlm-container-demo/NtlmDemo.csproj", "dotnet-ntlm-container-demo/"]
RUN dotnet restore "./dotnet-ntlm-container-demo/NtlmDemo.csproj"
COPY . .
WORKDIR "/src/dotnet-ntlm-container-demo"
RUN dotnet build "./NtlmDemo.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./NtlmDemo.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "NtlmDemo.dll"]
And a Dockerfile that works (Note: the only change is the image tag):
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim AS base
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
RUN apt-get update && apt-get install -y \
krb5-user \
libkrb5-dev \
gss-ntlmssp \
&& rm -rf /var/lib/apt/lists/*
USER app
FROM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["dotnet-ntlm-container-demo/NtlmDemo.csproj", "dotnet-ntlm-container-demo/"]
RUN dotnet restore "./dotnet-ntlm-container-demo/NtlmDemo.csproj"
COPY . .
WORKDIR "/src/dotnet-ntlm-container-demo"
RUN dotnet build "./NtlmDemo.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./NtlmDemo.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "NtlmDemo.dll"]
Other Information
Output of docker version
Docker version 25.0.3, build 4debf41
Metadata
Metadata
Assignees
Type
Projects
Status