Replace the RDP certificate

Every Windows machine creates a self-signed certificate for Remote Desktop. That is where the warning on connect comes from. With a certificate from a trusted CA the warning disappears, and the client can verify it is really talking to the right server.

Which certificate?

If you have certificate and key as PEM files, the certificate converter turns them into a PFX file. Then import it:

$pw = Read-Host -AsSecureString "PFX password"
Import-PfxCertificate -FilePath C:\temp\rdp.pfx -CertStoreLocation Cert:\LocalMachine\My -Password $pw

Assign the certificate to Remote Desktop

The service takes the certificate by its thumbprint:

$thumb = (Get-ChildItem Cert:\LocalMachine\My |
  Where-Object { $_.Subject -like "*ts01.corp.local*" } |
  Sort-Object NotAfter -Descending | Select-Object -First 1).Thumbprint

$ts = Get-CimInstance -Namespace root/cimv2/TerminalServices -ClassName Win32_TSGeneralSetting -Filter "TerminalName='RDP-tcp'"
Set-CimInstance -InputObject $ts -Property @{ SSLCertificateSHA1Hash = $thumb }

New connections use the certificate right away; no reboot needed. Check it in the RDP client via the lock icon in the connection bar, or with:

(Get-CimInstance -Namespace root/cimv2/TerminalServices -ClassName Win32_TSGeneralSetting).SSLCertificateSHA1Hash

Private key permissions

The Remote Desktop service runs as NETWORK SERVICE and must be able to read the key. Without that permission Windows silently falls back to the self-signed certificate, and the event log (System, source Schannel or TermDD) shows an error. Fix: certlm.msc → certificate → All Tasks → Manage Private Keys → add NETWORK SERVICE with read access.

Many servers: group policy

With an enterprise CA this can be automated. Create a certificate template with Server Authentication (a copy of “Computer”) and enter its name in the policy:

Computer Configuration → Administrative Templates → Windows Components → Remote Desktop Services → Remote Desktop Session Host → Security → Server authentication certificate template

The servers then enroll the certificate themselves and renew it in time.

RDS deployment with gateway and web access

In an RDS farm the certificates are set centrally: Server Manager → Remote Desktop Services → Deployment Properties → Certificates. Or with PowerShell, per role:

$pw = Read-Host -AsSecureString
foreach ($r in "RDGateway","RDWebAccess","RDRedirector","RDPublishing") {
  Set-RDCertificate -Role $r -ImportPath C:\temp\rds.pfx -Password $pw -ConnectionBroker cb01.corp.local -Force
}

The gateway is reachable from outside. Check chain and validity there with the SSL check, and the certificate expiry overview makes sure you don’t miss the renewal.

Let's Encrypt for RDP

For servers with a public name, win-acme is the usual choice on Windows. It ships installation scripts for RDP and RD Gateway that assign the new certificate after every renewal. For internal names Let's Encrypt only works with DNS validation; an internal CA is usually simpler there.

FAQ

Why does the warning still appear with the new certificate?

Usually users connect with a name that is not in the certificate, such as the IP address or short name, or the client lacks the issuing CA.

Can I delete the self-signed certificate?

Yes, Windows recreates it when needed. It lives in the Remote Desktop store. As long as your own certificate is assigned, it is not used.

Does this also apply to Windows clients with Remote Desktop enabled?

Yes, the procedure on Windows 10 and 11 is the same as on Windows Server.

Sources and documentation