The Answer from Steve Sheldon fixed the problem for me, however, as I am scripting certificate permissions with out a gui, I needed a scriptable solution. I struggled to find where my private key was stored . The private key was not in -C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys
, eventually I found that it was actually in C:\ProgramData\Microsoft\Crypto\Keys
. Below I describe how I found that out:
I tried FindPrivateKey
but it could not find the private key, and using powershell the $cert.privatekey.cspkeycontainerinfo.uniquekeycontainername
was null/empty.
Luckily, certutil -store my
listed the certificate and gave me the details I needed to script the solution.
================ Certificate 1 ================
Serial Number: 162f1b54fe78c7c8fa9df09
Issuer: CN=*.internal.xxxxxxx.net
NotBefore: 23/08/2019 14:04
NotAfter: 23/02/2020 14:24
Subject: CN=*.xxxxxxxnet
Signature matches Public Key
Root Certificate: Subject matches Issuer
Cert Hash(sha1): xxxxa5f0e9f0ac8b7dd634xx
Key Container = {407EC7EF-8701-42BF-993F-CDEF8328DD}
Unique container name: 8787033f8ccb5836115b87acb_ca96c65a-4b42-a145-eee62128a
##* ^-- filename for private key*##
Provider = Microsoft Software Key Storage Provider
Private key is NOT plain text exportable
Encryption test passed
CertUtil: -store command completed successfully.
I then scanned c\ProgramData\Microsoft\Crypto\
folder and found the file 8787033f8ccb5836115b87acb_ca96c65a-4b42-a145-eee62128a in C:\ProgramData\Microsoft\Crypto\Keys .
Giving my service account read access this file fixed the issues for me