microsoft / microsoft/Windows-Containers
Allow importing trusted root certificates into the per-user root store as ContainerUser
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 551
- Forks
- 76
- PR merge metrics
- No merged PRs in 30d
Description
Is your feature request related to a problem? Please describe.
When developing container-based distributed applications (e.g., based on microservices), it's often required to import custom trusted root certificates at container startup time. It's considered best practice to run such containers under the ContainerUser account, not the ContainerAdministrators account. As the ContainerUser account cannot import certificates into the machine store, the certificate must be imported into the user store.
However, this fails with the following error:
The operation was canceled by the user. 0x800704c7 (WIN32: 1223 ERROR_CANCELLED)
This is probably due to Windows trying to present an interactive dialog box (which you can see on a desktop system). Of course, this doesn't work in a container or in any other non-interactive setting.
Describe the solution you'd like
Importing trusted root certificates into the user store should just work. Or at least there should be a switch to make it possible.
Describe alternatives you've considered
- Importing the certificate into the machine store works when the container entrypoint is running under the
ContainerAdministratoraccount. However, this is considered bad practice from a security point of view. - Importing the certificate into the machine store as
ContainerAdministratorduring the image build phase (from the Dockerfile), then switching toContainerUserworks, but is not an option for us, as the certificates aren't known at image build time. On the one hand, for our own deployments, the lifecycle of those certificates is different from that of our containers/container images. On the other hand, we distribute our container images to external users and we cannot know what certificates they use. - Starting the container entrypoint under
ContainerAdministrator, then, after importing the certificates into the machine store, switching toContainerUsersomehow might be an option, but we don't know how to implement that.
Additional context
Here's a repro sample with certoc.exe (must be in the current directory):
Host> docker run -it --rm -v .:C:/Certificates mcr.microsoft.com/dotnet/sdk:8.0-nanoserver-ltsc2022
Microsoft Windows [Version 10.0.20348.2461]
(c) Microsoft Corporation. All rights reserved.
C:\>cd certificates
C:\certificates>copy con mycertificate.cer
-----BEGIN CERTIFICATE-----
MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCB
vTELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL
ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAY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B0GA1Ud
DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4
sAPmLGd75JR3Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+
seQxIcaBlVZaDrHC1LGmWazxY8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz
4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTxP/jgdFcrGJ2BtMQo2pSXpXDrrB2+
BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+PwGZsY6rp2aQW9IHR
lRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4mJO3
7M2CYfE45k+XmCpajQ==
-----END CERTIFICATE-----
^Z
1 file(s) copied.
C:\certificates>certoc -addstore -User root mycertificate.cer
Store(root) User:
The operation was canceled by the user. 0x800704c7 (WIN32: 1223 ERROR_CANCELLED)
And here is a follow-up trying the same with PowerShell:
C:\certificates>pwsh
PowerShell 7.4.2
PS C:\certificates> $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("mycertificate.cer")
PS C:\certificates> $rootStore = New-Object System.Security.Cryptography.X509Certificates.X509Store("root", "CurrentUser")
PS C:\certificates> $rootStore.Open("MaxAllowed")
PS C:\certificates> $rootStore.Add($cert)
MethodInvocationException: Exception calling "Add" with "1" argument(s): "The operation was canceled by the user."
PS C:\certificates> $rootStore.Close()
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The payload names no repository files or tests. Start by reproducing the certoc.exe and PowerShell CurrentUser/root-store commands as ContainerUser, then inspect the relevant Windows-container certificate behavior. Done means a trusted root certificate can be imported into the per-user store without an interactive prompt.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, powershell
- Domain
- infrastructure, operating-systems, security
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100