How to import a pfx using certutil without prompt?

Amol Manthalkar picture Amol Manthalkar · Oct 28, 2014 · Viewed 25.9k times · Source

I want to import a pfx using cmd. I am using certutils for that. But I am getting a prompt asking to trust the certificate. I want to automatize import so I want to skip the warning prompt. How can I accomplish that?

Warning Prompt

I am using command certutil -f -user -p PASSWORD -importpfx c:\cert.pfx

Answer

iericzhou picture iericzhou · Oct 29, 2015

The reason you got a prompt dialog is that you are trying to add a "CA certificate" into the "Trusted Root Certification Authorities" store. In fact, when you use "certutil -f -user -p PASSWORD -importpfx c:\cert.pfx" to import a PFX certificate, two actions happen:

  1. Add a personal certificate(which includes the private key) into the "Personal" store.
  2. Add a CA certificate into the "Trusted Root Certification Authorities" store.

It is the second action that cause the UAC to prompt a warning dialog, since you are trying to add one CA certificate into the "Trusted Root Certification Authorities" store and this means that any web host that holds this certicate will be trusted in the future, this is a very important action and should be treated very discreetly by the user, shouldn't it? So the UAC will warn the user to comfirm this action.

There is only one way to suppress the warning dialog, that is "you don't add the CA certificate into the "Trusted Root Certification Authorities" store by doing so:

 certutil -f -user -p PASSWORD -importpfx c:\cert.pfx NoRoot

Add personal certificate into "Personal" store will not prompt any warning dialog. However, by this way, the web host that holds the CA certificate will not be trusted any more and this can be very frustrating if you use HTTPS to access the web host.