r/sysadmin • • 4d ago

Question - Solved Root CA cert lands in Intermediate store and Trusted Root after autoenrollment

I've just built my first 2-tier PKI and published the root and intermediate certificates to AD with certutil -dspublish so domain joined devices pick them up automatically.

I noticed the root CA cert was getting placed in the Intermediate CA store as well as Trusted Root store on clients.

I read somewhere that autoenrollment copies the AD AIA container into the Intermediate store, and that publishing the root with certutil -dspublish puts a copy in AIA.

I deleted the root’s entry from CN=AIA,CN=Public Key Services,CN=Services,CN=Configuration in ADSI Edit and ran certutil -pulse on a test machine.

The root cert disappeared from the Intermediate store so I thought it was fixed, but I‘ve noticed the next time a device autoenrols for a template, the root is placed back into the Intermediate store.

I know this is probably harmless for chain validation, but I‘m just curious if this is expected behaviour.

7 Upvotes

13 comments sorted by

5

u/SandeeBelarus 4d ago

Install the ADCS RSAT tools. Open pkiview.msc

Then check the AD containers for where you published your certs. Each container corresponds to a use case. Two of the containers will place the certs that are in the stores in machine level trust stores by group policy.

I use this article as a reference. I quite like Marks work over the years and this is his company.

You can use this article to know what store places the cert where. Super easy fix as group policy will remove the cert from the corresponding trust store as you move them from the ad container. And vice versa with adding them back.

https://www.pkisolutions.com/understanding-active-directory-certificate-services-containers-in-active-directory/

The author of this article is my spirit animal Vadims Podans

1

u/Reconfirm7004 3d ago

Thank you Sandee, I wasn’t aware of pkiview so that’s good to know. I had actually already removed the root from the AIA container but through ADSI Edit. What I’ve found is that each time a machine autoenrolls via a template, the root is placed back in the Intermediate store. Based on other replies this appears to be expected behaviour.

3

u/Low-Branch1423 4d ago

Its a chain of things that cause this, and its just not clearly set or frankly maintained by MS

Dspublish doesn't distinguish between online and off-line CA. Your root ca is an issuing ca, of the intermediate.

When dspublish is used, the fact it is an issuing CA puts the cert in the AIA container

https://learn.microsoft.com/en-us/windows-server/security/authority-information-access-retrieval?tabs=gp

Everything in the AIA container is then pulled by clients into the intermediate store.

https://www.gradenegger.eu/en/root-authority-certificates-are-imported-into-the-certificate-store-for-intermediate-certification-authorities/

Remove it using cerutil or pkiview.

0

u/Reconfirm7004 3d ago

Thank you Low, that makes sense regarding why it gets placed in AIA after running dspublish. I had actually already removed it from the AIA container but found it would reappear as soon as a machine autoenrolled for a certificate. Based on other replies this appears to be expected behaviour.

3

u/davy_crockett_slayer 4d ago

Yes, that's expected. Two different things are putting it there.
certutil -dspublish -f root.crt RootCA writes the cert to both CN=Certification Authorities and CN=AIA. Autoenrollment copies Certification Authorities into Trusted Root and AIA into Intermediate. That's why deleting the AIA object and running a pulse removed it.

The reason it comes back is enrollment itself. The CA returns a PKCS#7 containing the whole chain. When CertEnroll installs that response, the issued cert goes to Personal and every CA cert in the chain, root included, goes to the Intermediate store. Every new enrollment drops it back in, and AD has nothing to do with it.

It's harmless. Trust comes from the Root store, and a self-signed cert sitting in Intermediate doesn't make anything trusted that wasn't already.
I wouldn't have deleted the AIA object. If your sub CA cert has an ldap:/// AIA URL pointing at CN=<root>,CN=AIA, that URL is dead now. certutil -verify -urlfetch against an issued cert will show it failing. Republish with the same command to put it back.

2

u/Reconfirm7004 3d ago

Thank you Davy, you’ve summarised exactly what I’m seeing! I’ll ignore it then if every enrolment is going to place it back there.

I’m not actually using LDAP, my sub CA only advertises HTTP as I require non-domain devices to be able to retrieve it as well. I figured it would be simpler to just use HTTP.

2

u/davy_crockett_slayer 3d ago

Gotcha. Nothing was looking up that AIA object, and deleting it didn't break anything. If you ever rerun certutil -dspublish ... RootCA, say when the root gets renewed, the object will come back.

If your CDP is HTTP as well and you publish delta CRLs, check that IIS has allowDoubleEscaping turned on for the CRL virtual directory. Delta CRL filenames end in +, and IIS request filtering blocks those by default, so non-domain clients fail revocation checks. certutil -verify -urlfetch from a non-domain machine will show whether it's working.

1

u/Reconfirm7004 1d ago

Thanks Davy, I have actually already enabled DoubleEscaping due to that exact issue!

2

u/ToilLess_Dev 4d ago

Hello Reconfirm7004,

the containers are covered above, but that doesn't explain why it comes back after you already removed it from AIA. As far as I know, that's the enrollment itself: when a client enrolls, the CA returns the issued cert with its chain, and Windows puts the CA certs from that response into the Intermediate store, including the self-signed root. So every autoenrollment drops it back in, no matter what's in AIA.

It's harmless, though. Trust comes only from the Trusted Root store, so a root in Intermediate doesn't make anything trusted that wasn't already. I'd leave it alone rather than fight it.

1

u/Reconfirm7004 3d ago

Thank you Toil, what you’ve said aligns with the other responses. Windows seems to return a PKCS#7 containing the whole chain during enrolment, then places each CA cert in the Intermediate store. I’ll ignore it now that I know why it’s happening!

2

u/Cormacolinde Consultant 4d ago

This is perfectly normal and expected. It does not cause issues. The reverse, putting a non-root CA in the root CA store can be catastrophic.

1

u/Reconfirm7004 3d ago

Thanks Corma, I’ll just ignore it then!

2

u/Optanik 2d ago

It's expected and harmless. certutil -dspublish with RootCA writes the root to both the Certification Authorities container and the AIA container by design. Autoenrollment then syncs the AIA container into the Intermediate store, so the duplicate is normal. If it comes back after you deleted the AIA entry, check two things. First, confirm the AD object is really gone. Look in ADSI Edit again on a DC the client actually talks to, since a DC that hasn't replicated can still hand it out. Second, if AD is clean, the copy is probably coming from the enrollment itself. When the client installs the issued certificate, it usually adds the chain from the CA's response to the local stores, and the root can land in Intermediate that way. Running certutil -enterprise -store CA and certutil -store CA side by side shows which path it came from. Chain building doesn't care about an extra copy of the root in Intermediate, so most people leave the default AIA publication in place and move on.