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

John R
  • 383
  • 4
  • 13

1 Answers1

14

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
John R
  • 383
  • 4
  • 13