6

I would like to know if there is a cmd to copy an existing certificate from one store to another. I am trying to copy a certificate from the Users Intermediate Certification Authorities store (certutils -user -store ca fqdn-HOST-CA) to the machine's Trusted Root Certification Authorities store (certutils -store root fqdn-HOST-CA). I tried piping the cmds together with -addstore but no worky!!

certutil.exe -addstore root | certutil.exe -store -user ca fqdn-HOST-CA

Any ideas? Thanks

1 Answer 1

15

I think using PowerShell might be the way to go.

$srcStoreScope = "CurrentUser"
$srcStoreName = "CA"

$srcStore = New-Object System.Security.Cryptography.X509Certificates.X509Store $srcStoreName, $srcStoreScope
$srcStore.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadOnly)

$cert = $srcStore.certificates -match "sometext"

$dstStoreScope = "LocalMachine"
$dstStoreName = "root"

$dstStore = New-Object System.Security.Cryptography.X509Certificates.X509Store $dstStoreName, $dstStoreScope
$dstStore.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite)
$dstStore.Add($cert[0])

$srcStore.Close
$dstStore.Close

#Write-Output $cert
3
  • Worked like a charm Mar 17, 2015 at 15:31
  • Worked like a charm Feb 8, 2016 at 14:56
  • Charmed like a work
    – JOpuckman
    Oct 16, 2018 at 12:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .