You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Subject order and missing DC attributes when signing intermediate CA with smallstep (Microsoft CA compatibility issue) #1606
If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)
Issue details
Hi everyone,
I’m currently trying to use a smallstep root CA to sign a Microsoft Windows CA as a subordinate CA, but I’m running into issues with the subject field handling.
Here’s my setup:
I created a CSR for the Microsoft CA.
Then I signed it using my smallstep root CA with:
With this template, the extensions are now correct and accepted.
However, I’m facing a new issue with the subject:
In my CSR (.req), the subject looks like this:
CN=abc, DC=def, DC=ghi
When I use:
"subject": {{ toJson .Insecure.CR.Subject }}
the subject in the issued certificate becomes:
DC=ghi, DC=def, CN=abc
→ so all attributes are present, but the order is reversed.
If I instead use:
"subject": {{ toJson .Subject }}
then the resulting certificate only contains:
CN=abc
which makes sense because the template overrides the subject and only includes the CN.
Problem:
Microsoft CA seems to reject the certificate when the subject order is changed, even though the same attributes are present.
According to the documentation and discussions (e.g. issue #718), I expected .Insecure.CR.Subject to preserve the subject exactly as defined in the CSR — including the order — but that does not seem to be the case.
Questions:
Is the reordering of subject attributes when using .Insecure.CR.Subject expected behavior?
Is there any way to preserve the exact original subject order from the CSR?
Has anyone successfully used smallstep to sign a Microsoft subordinate CA certificate without running into this issue?
Any help would be greatly appreciated — I’m currently stuck on this.
Thanks!
Why is this needed?
The .Insecure.CR.Subject Option in templates doesn't work like it should.
I'm not aware of other users running into this issue. Generally people are going the other way while migrating away from or in co-operation with ADCS: signing an intermediate off of ADCS, and use that with step-ca. What is your use case, exactly?
It seems this may be some quirk with ADCS, potentially doing a form of strict string comparison on the subject. We don't have much time to look into this now ourselves, but we'd be open to contributions, assuming the changes are not too invasive.
quick update on my original question and also a bit more context on our use case.
We are moving away from Microsoft Active Directory Certificate Services completely and switch fully to Smallstep CA. However, due to the Microsoft auto-enrollment feature (for laptops and Windows servers), we still need to keep the Microsoft CA in place, at least for now. That’s why the goal is to run the Microsoft CA as a subordinate CA under Smallstep.
Current Status
Unfortunately, I was not able to fully solve the issue within Smallstep.
However, I did find some interesting behavior:
When using the --csr profile, the subject order is preserved correctly
When signing the CSR without any template, the subject order is also correct
But: in that case, I cannot add required extensions like AIA and CDP
As soon as I use:
a custom template (any template), or
the --profile intermediate-ca
the order of the subject attributes (CN, DC, etc.) gets rearranged.
So the behavior seems to be:
✅ Correct order → only when NOT using templates
❌ Reordered subject → whenever a template or intermediate profile is used
Workaround (using OpenSSL)
As a workaround, I ended up signing the CSR using OpenSSL instead of Smallstep.
This allows preserving the subject order and adding the required extensions.
The downside: I had to set up a separate OpenSSL “database” (text file–based CA structure).
Create directory structure
mkdir -p /etc/step-ca/microsoft-ca/{certs,crl,newcerts,private}
cd /etc/step-ca/microsoft-ca
Create “database”
touch microsoft-ca-db
echo 1000 > serial
echo 1000 > crlnumber
from the root CA and made them available via a separate HTTP endpoint, since the root CA itself is offline.
Conclusion
So in summary:
Smallstep works fine without templates, but then lacks required extensions
As soon as templates are used, the subject order changes, which breaks compatibility with Microsoft CA
The only working solution for me so far is using OpenSSL with -preserveDN
If anyone has managed to solve this cleanly within Smallstep, I’d still be very interested in hearing about it.
Activity
hslatman commentedon Apr 2, 2026
Hey @JannikZorn,
I'm not aware of other users running into this issue. Generally people are going the other way while migrating away from or in co-operation with ADCS: signing an intermediate off of ADCS, and use that with
step-ca. What is your use case, exactly?It seems this may be some quirk with ADCS, potentially doing a form of strict string comparison on the subject. We don't have much time to look into this now ourselves, but we'd be open to contributions, assuming the changes are not too invasive.
JannikZorn commentedon Apr 9, 2026
Hi everyone,
quick update on my original question and also a bit more context on our use case.
We are moving away from Microsoft Active Directory Certificate Services completely and switch fully to Smallstep CA. However, due to the Microsoft auto-enrollment feature (for laptops and Windows servers), we still need to keep the Microsoft CA in place, at least for now. That’s why the goal is to run the Microsoft CA as a subordinate CA under Smallstep.
Current Status
Unfortunately, I was not able to fully solve the issue within Smallstep.
However, I did find some interesting behavior:
When using the --csr profile, the subject order is preserved correctly
When signing the CSR without any template, the subject order is also correct
But: in that case, I cannot add required extensions like AIA and CDP
As soon as I use:
a custom template (any template), or
the --profile intermediate-ca
the order of the subject attributes (CN, DC, etc.) gets rearranged.
So the behavior seems to be:
✅ Correct order → only when NOT using templates
❌ Reordered subject → whenever a template or intermediate profile is used
Workaround (using OpenSSL)
As a workaround, I ended up signing the CSR using OpenSSL instead of Smallstep.
This allows preserving the subject order and adding the required extensions.
The downside: I had to set up a separate OpenSSL “database” (text file–based CA structure).
Check database:
cat /etc/step-ca/microsoft-ca/microsoft-ca-dbAdditional Notes
After signing with OpenSSL, I extracted:
from the root CA and made them available via a separate HTTP endpoint, since the root CA itself is offline.
Conclusion
So in summary:
Smallstep works fine without templates, but then lacks required extensions
As soon as templates are used, the subject order changes, which breaks compatibility with Microsoft CA
The only working solution for me so far is using OpenSSL with -preserveDN
If anyone has managed to solve this cleanly within Smallstep, I’d still be very interested in hearing about it.
Thanks again!