Skip to content

[package] Replace manual SecPkgContext_CipherInfo struct with CsWin32-generated version #556

@DeagleGross

Description

@DeagleGross

Summary

CsWin32 (v0.3.269) can generate SecPkgContext_CipherInfo from the Win32 metadata in the Windows.Win32.Security.Authentication.Identity namespace. This PR removes the manually-defined struct and uses the CsWin32-generated version.

Version change

No version bump — the existing CsWin32 version (0.3.269) already supports this type. GitHub API access was restricted (403) due to token lifetime policy, so the latest available NuGet version could not be verified externally; only the locally cached 0.3.269 was confirmed.

Workarounds fixed

src/Shared/HttpSys/NativeInterop/SecPkgContext_CipherInfo.cs

Manual struct definition removed. The file previously hand-defined SecPkgContext_CipherInfo (from Schannel.h) in the Microsoft.AspNetCore.HttpSys.Internal namespace using [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] and fixed char[64] fields.

CsWin32 generates an equivalent struct using __char_64 inline array wrappers (also [StructLayout(Sequential, CharSet = Unicode)]) which are binary-compatible with the previous definition. The struct file is replaced with a placeholder comment.

Consumer files updated:

  • src/Servers/HttpSys/src/RequestProcessing/RequestContext.cs — added using Windows.Win32.Security.Authentication.Identity;
  • src/Servers/IIS/IIS/src/Core/IISHttpContext.cs — added using Windows.Win32.Security.Authentication.Identity;

NativeMethods.txt files updated:

  • src/Servers/HttpSys/src/NativeMethods.txt — added SecPkgContext_CipherInfo
  • src/Servers/IIS/IIS/src/NativeMethods.txt — added SecPkgContext_CipherInfo

Workarounds that remain

  • GetProcAddress-based P/Invoke for HttpQueryRequestProperty / HttpSetRequestProperty (HttpApi.cs): These are deliberately loaded via GetProcAddress at runtime for availability detection (graceful fallback on older Windows). This is intentional design, not a CsWin32 workaround.

Build verification

Both affected projects build successfully with 0 errors, 0 warnings:

dotnet build src/Servers/HttpSys/src/Microsoft.AspNetCore.Server.HttpSys.csproj
→ Build succeeded. 0 Warning(s), 0 Error(s)

dotnet build src/Servers/IIS/IIS/src/Microsoft.AspNetCore.Server.IIS.csproj
→ Build succeeded. 0 Warning(s), 0 Error(s)

Generated by Update CsWin32 Package · sonnet46 6.9M ·


Note

This was originally intended as a pull request, but the git push operation failed.

Workflow Run: View run details and download bundle artifact

The bundle file is available in the agent artifact in the workflow run linked above.

To create a pull request with the changes:

# Download the artifact from the workflow run
gh run download 26735994773 -n agent -D /tmp/agent-26735994773

# Fetch the bundle into a temporary ref, then update the local branch
git fetch /tmp/agent-26735994773/aw-cswin32-replace-manual-secpkgcontext_cipherinfo.bundle refs/heads/cswin32-replace-manual-SecPkgContext_CipherInfo:refs/bundles/create-pr-cswin32-replace-manual-SecPkgContext-CipherInfo-aa71629a0f4e1b48-79ff9197
git update-ref refs/heads/cswin32-replace-manual-SecPkgContext_CipherInfo-aa71629a0f4e1b48 refs/bundles/create-pr-cswin32-replace-manual-SecPkgContext-CipherInfo-aa71629a0f4e1b48-79ff9197
git checkout cswin32-replace-manual-SecPkgContext_CipherInfo-aa71629a0f4e1b48
# Ensure the working tree matches the updated branch
git reset --hard
# Remove the temporary bundle ref
git update-ref -d refs/bundles/create-pr-cswin32-replace-manual-SecPkgContext-CipherInfo-aa71629a0f4e1b48-79ff9197

# Push the branch to origin
git push origin cswin32-replace-manual-SecPkgContext_CipherInfo-aa71629a0f4e1b48

# Create the pull request
gh pr create --title '[package] Replace manual SecPkgContext_CipherInfo struct with CsWin32-generated version' --base main --head cswin32-replace-manual-SecPkgContext_CipherInfo-aa71629a0f4e1b48 --repo DeagleGross/aspnetcore

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions