Hi 49885604,
You are stretching my memory here but I'll give it a crack and recommend you check verify my thoughts (ideally in a test environment or LAB). I will skip the whole 'why are you reusing keys?' question as I assume you have reasons. Basically, from memory, you need to have a certificate and private key available and associated in windows for the CA to use.
- for .key file - (I am assuming this is still the case with windows) - you need to convert the cert and key files to PFX, then import to windows. The import will ensure the private key and certificate are installed in the machine certificate store and correctly associated. I'll provide some references on how you may be able to convert from PEM to PFX (verify and use at your own risk) below.
- For HSM - Generally you cannot 'import' the private key to windows as the HSM is supposed to protect it. I guess that really depends on the HSM and how the Key was originally protected. The point of an HSM is usually to prevent exposure of the private key outside of the HSM - therefore you cannot usually export a private key from an HSM. Caveate - in a usable form.
What you want to do here is install the certificate associated with the HSM protected key into the windows machine certificate store. Assuming the HSM software is installed on the CA and the CA is configured and talking to the HSM, you should then be able to associate the certificate in the machine certificate store with the HSM Key Storage Provider (KSP) which then enables the crypto functions that need the private key to be redirected to the HSM. This association may be able to be done with the HSM software and/or you may need to use certutil -repairstore to perform the association.
I hope the above gets you started in the right direction. It has been a while so please take with several grains of salt.
References for PEM/Key to PFX... (verify and test and try at your own risk)
https://security.stackexchange.com/questions/25996/how-to-import-a-private-key-in-windows
Regards,
Geoff