Install NTDS Service Certificate for LDAPS on Windows Server Core
Import the PFX File
$pword = Read-Host -AsSecureString
# enter the password to extract the PFX file
$splat = @{
Password = $pword
CertStoreLocation = 'Cert:\LocalMachine\My\'
FilePath = '.\your-pfx-file-name.pfx'
}
Import-PfxCertificate -Exportable @splat
# on success, it outputs the certificate thumbnailExport the Registry Key
reg export HKLM\SOFTWARE\Microsoft\SystemCertificates\My\Certificates\your-certificate-thumbprint cert_export.regReplace your-certificate-thumbprint with your actual certificate thumbprint.
Edit the Registry File
notepad cert_export.regReplace the top level registry key information as follows:
Original:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SystemCertificates\My\Certificates\your cert thumbprint goes here]
Replacement:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\Services\NTDS\SystemCertificates\My\Certificates\your cert thumbprint goes here]
Replace the original registry header with the replacement. Don’t forget to replace the your cert thumbprint goes here with your actual certificate thumbprint–otherwise, the certificate will not work.
Save the file (Ctrl-S) and continue on to the import.
Import the Registry Key
reg import cert_export.regConfirm it Installed
Even on Windows Server Core, you can use the regedit.exe graphical registry editor. To check the import, execute regedit.exe.
- Open the HKEY_LOCAL_MACHINE registry key
- Expand the following subkeys
- SOFTWARE
- Microsoft
- Cryptography
- Services
- NTDS
- SystemCertificates
- My
- Certificates
- The Certificate Thumbprint
Import-PfxCertificate command.You should see a blob value containing the binary data for the certificate and the keys. If you don’t, confirm the data (especially the piece you replaced) in the registry export file.
Delete the LocalMachine Certificate
certutil -delstore My your-certificate-thumbprint-goes-hereAgain, replace the your-certificate-thumbprint-goes-here with the above certificate thumbprint. Then, reboot.
shutdown /r /t 0