Skip to content

Add Windows CA certificate injection support for servercore images#954

Draft
gdams wants to merge 6 commits into
adoptium:mainfrom
gdams:windows-cacerts
Draft

Add Windows CA certificate injection support for servercore images#954
gdams wants to merge 6 commits into
adoptium:mainfrom
gdams:windows-cacerts

Conversation

@gdams

@gdams gdams commented May 12, 2026

Copy link
Copy Markdown
Member

Summary

Adds a PowerShell entrypoint for Windows Server Core containers that provides CA certificate injection parity with the existing Linux entrypoint.sh.

Changes

  • docker_templates/entrypoint.ps1.j2 — New PowerShell entrypoint template, equivalent to entrypoint.sh.j2 for Linux:

    • Imports certificates from the Windows certificate store (Cert:\LocalMachine\Root) into the JVM truststore
    • Imports user-provided certificates from C:\certificates\*.crt
    • Opt-in via USE_SYSTEM_CA_CERTS environment variable (same as Linux)
    • Handles read-only truststore via temporary copy + JAVA_TOOL_OPTIONS
    • Correct truststore paths for JDK 8 vs 11+
  • docker_templates/servercore.Dockerfile.j2 — Wires the entrypoint into servercore images with COPY and ENTRYPOINT directives

  • generate_dockerfiles.py — Generates entrypoint.ps1 alongside Dockerfiles for servercore builds

  • test_generate_dockerfiles.py — Test parity with Linux entrypoint tests:

    • test_entrypoint_ps1_rendering — validates cert store import, command forwarding, truststore paths for JDK 8/11+/JRE
    • test_servercore_entrypoint_wiring — validates COPY/ENTRYPOINT in generated Dockerfile
  • .test/config.sh — Enables java-ca-certificates-update test for windowsservercore (nanoserver remains excluded — no PowerShell)

Depends on #952

gdams added 2 commits May 12, 2026 13:33
Servercore-only equivalent of entrypoint.sh for Linux. When
USE_SYSTEM_CA_CERTS is set, imports certificates from the Windows
certificate store (Cert:\LocalMachine\Root) and from C:\certificates\*.crt
into the JVM truststore using keytool.

This is a prototype — not yet wired into the servercore Dockerfile template
or the generator.
- Add COPY and ENTRYPOINT directives to servercore.Dockerfile.j2
- Generate entrypoint.ps1 alongside Dockerfile for servercore builds
- Add test parity: entrypoint.ps1 rendering and servercore wiring tests
- Enable java-ca-certificates-update test for windowsservercore
@gdams gdams force-pushed the windows-cacerts branch from e4c3b8a to 95ea353 Compare May 12, 2026 12:35
gdams added 4 commits May 12, 2026 13:42
- Add exit $LASTEXITCODE to entrypoint.ps1 so child process exit codes
  propagate correctly (PowerShell does not replace the process like
  exec does in bash)
- Add Windows branch to java-ca-certificates-update/run.sh that uses
  cmd /C instead of sh -c, mounts at C:/certificates, and builds a
  custom PowerShell entrypoint image for the override test
- Skip Phase 2 (non-root) on Windows — --user and --read-only are not
  supported on Windows containers
- Add custom-entrypoint.ps1 for the entrypoint override test
- Ensure generated entrypoint.ps1 files end with a trailing newline
- Add catch blocks to both try/finally in entrypoint.ps1 so that
  individual cert import failures (e.g. unexportable system certs)
  don't terminate the entrypoint ($ErrorActionPreference = 'Stop')
- Export MSYS_NO_PATHCONV=1 in the Windows test branch to prevent
  Git Bash from mangling C:/certificates volume mount paths (exit 125)
@gdams gdams marked this pull request as draft May 12, 2026 14:05
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

Successfully merging this pull request may close these issues.

1 participant