Forum Discussion

vdrjrmylair's avatar
vdrjrmylair
Copper Contributor
Apr 04, 2023
Solved

Import certificate with automatic store affectation

Hi, I would like to know if there is a way to import certificates to the local computer store without specifying the store location using the Import-Certificate cmdlet ? What I want I want that th...
  • LainRobertson's avatar
    LainRobertson
    Apr 04, 2023

    vdrjrmylair 

     

    So, it's not actually the system (i.e. Windows) that looks at the certificate and makes a decision on where to place it. It's the MMC - or more correctly the snap-in, which is just a .dll "program" - that contains that logic.

     

    With respect to the "how", that snap-in will look at various fields such as the key and enhanced key usages (sample provided below from a root authority) and make a "best guess" at where the certificate should possibly go.

     

     

    But this is still a guess and why it provides the user with the ability to manually specify where the certificate should go, which recognises the fact that its own logic can definitely get it wrong.

     

    This MMC snap-in is analogous to you writing your own script - i.e. the final point I made above. You can go to great lengths to try and reproduce what that snap-in does using PowerShell but it would only ever be to varying degrees of success.

     

    So, there's nothing automatic about the placement. As I said earlier, any certificate can be placed in any store. It's just the Certificates "program" has some logic in it to make educated guesses, while the PowerShell PKI module commandlets does not (again, you'd have to do that coding yourself.)

     

    Cheers,

    Lain

Resources