SSL certificates can be valid for at most 199 days. By 15 March 2027 the limit becomes 99 days, for DigiCert certificates from 24 February 2027. Read more →

RDP and RD Gateway: SSL certificate setup

Remote Desktop Gateway uses HTTPS to tunnel RDP traffic securely over the internet. This guide covers certificate requirements, automated setup with simple-acme, manual installation with PowerShell, Server Manager and RD Gateway Manager, GPO distribution to RDP servers and troubleshooting.

Supported versions

Remote Desktop ServicesVersionsRD Gateway (also without an RD Connection Broker), RD Web Access, RD Web Client, RD Connection Broker and the RDP listenerRuns onWindows Server 2012 or newerACME clientsimple-acme 2.4.0+ (FairSSL edition, .NET 10 included) + ImportRDSFullFairSSL.ps1

Architecture

A typical Remote Desktop setup with a gateway has multiple components, each requiring certificates:

Internet client

MSTSC / Remote Desktop

RD Gateway

HTTPS (port 443)

Public certificate

RD Web Access

IIS (port 443)

Public certificate

RDP servers

Internal network

Internal/public cert

RD Gateway and RD Web Access typically run on the same server.

Certificate requirements

Component Certificate type Hostname Note
RD Gateway Public (DV/OV) rdp.your-domain.com Internet-facing, public CA required
RD Web Access Public (DV/OV) rdp.your-domain.com Same hostname as gateway (IIS binding)
RDP servers Internal / public server01.internal.com NLA authentication only

Setup with simple-acme

Simple-acme automates the entire certificate lifecycle: issuance, installation in Windows Certificate Store, IIS binding and binding to all RDP services. With FairSSL’s ImportRDSFullFairSSL.ps1 script, RD Gateway, RD Connection Broker, RD Web Access and the RDP listener are handled automatically on every renewal.

Simple-acme command

simple-acme.exe ^
  --baseuri https://fairssl.dk/acme/ ^
  --source manual ^
  --host rdp.your-domain.com ^
  --validationmode dns-01 ^
  --validation cloudflare ^
  --cloudflareapitoken YOUR_CF_TOKEN ^
  --csr ec ^
  --store certificatestore ^
  --installation iis,script ^
  --siteid 1 ^
  --script "Scripts\ImportRDSFullFairSSL.ps1" ^
  --scriptparameters "{CertThumbprint}" ^
  --accepttos

What happens automatically?

When simple-acme runs (manually or via Task Scheduler), it performs these steps:

  1. 1 Issues or renews the certificate via ACME with DNS-01 validation
  2. 2 Imports the certificate into Windows Certificate Store (Cert:\LocalMachine\My)
  3. 3 Updates the IIS HTTPS binding (--installation iis)
  4. 4 Runs ImportRDSFullFairSSL.ps1 which binds the certificate to RD Gateway, RD Connection Broker, RD Web Access and the RDP listener, and restarts the relevant services

Important settings in settings.json

In simple-acme's settings.json (or settings_default.json), set:

  • Store.CertificateStore.PrivateKeyExportable to true (required for RDP services)
  • ScheduledTask.RenewalMinimumValidDays to 15 (renew at least 15 days before expiry)

DNS validation with FairSSL AutoDNS

If you do not have API access to your DNS provider, you can use FairSSL AutoDNS instead of Cloudflare. Set up a CNAME record once, and FairSSL handles all DNS validation automatically:

# DNS: one-time CNAME setup
_dnsauth.your-domain.com  CNAME  your-unique-id.autodns.fairssl.dk.

See the simple-acme guide for full documentation of script parameters and Task Scheduler configuration.

Install the certificate manually

Without simple-acme, where you install the certificate depends on the setup:

Setup Method Windows Server in Microsoft's documentation
One server with Remote Desktop, not part of an RDS deployment 1. RDP listener via WMI Supported versions; wmic shown for 2012 R2 and older, PowerShell for 2025
RDS deployment with RD Connection Broker 2. Server Manager or 4. Set-RDCertificate 2016, 2019, 2022, 2025
RD Gateway on its own 3. RD Gateway Manager 2016, 2019, 2022, 2025

The steps and commands follow Microsoft Learn. Each subsection links to the page it is based on. Replace THUMBPRINT with the certificate's thumbprint and the host names with your own.

1. RDP listener on one server (Win32_TSGeneralSetting)

The RDP listener finds its certificate through the thumbprint in the SSLCertificateSHA1Hash property of the WMI class Win32_TSGeneralSetting in the namespace Root\CimV2\TerminalServices. Microsoft describes this method for a server that is not part of an RDS deployment.

  1. 1 Import the certificate with its private key into the Personal store of the computer account (certlm.msc). If it is not there, the command in step 4 fails with Invalid Parameter.
  2. 2 Open the certificate, select the Details tab and copy the Thumbprint value. Remove all spaces. On Windows Server 2012 R2 and older the copied value can contain an invisible character; paste it into a command prompt to see it, and remove it.
  3. 3 Give NETWORK SERVICE read access to the private key. Remote Desktop runs under that account. In certlm.msc, expand Personal, right-click the certificate, select All Tasks → Manage Private Keys, select Add, type NETWORK SERVICE, select OK, tick Read under Allow and select OK.
  4. 4 Set the thumbprint on the listener with Windows PowerShell:
Get-WmiObject -class "Win32_TSGeneralSetting" -Namespace root\cimv2\terminalservices | Set-WmiInstance -Arguments @{SSLCertificateSHA1Hash="THUMBPRINT"}

Run it in Windows PowerShell 5.1 (powershell.exe): Get-WmiObject and Set-WmiInstance were removed in PowerShell 7 (pwsh.exe). On Windows Server 2012 and 2012 R2 Microsoft shows the same change with wmic in a command prompt:

wmic /namespace:\\root\cimv2\TerminalServices PATH Win32_TSGeneralSetting Set SSLCertificateSHA1Hash="THUMBPRINT"

Microsoft lists wmic as deprecated from Windows Server 21H1 and points to PowerShell instead.

Check the result by reading the class with Get-WmiObject alone. SSLCertificateSHA1Hash must show your thumbprint, and SSLCertificateSHA1HashType must be 3 (Custom). 1 means the listener still uses the default self-signed certificate.

Get-WmiObject -class "Win32_TSGeneralSetting" -Namespace root\cimv2\terminalservices

Sources: Remote Desktop listener certificate configurations ↗, Win32_TSGeneralSetting class ↗, wmic ↗, Get-WmiObject (PowerShell 5.1) ↗, Differences between Windows PowerShell 5.1 and PowerShell 7.x ↗ (Microsoft Learn).

2. RDS deployment via Server Manager

In an RDS deployment with RD Connection Broker you set the certificates for the whole deployment. Server Manager imports the certificate on every server in the deployment and binds it to their roles. The certificate must be issued for Server Authentication, be trusted by the servers and the clients, and have an exportable private key. You need it as a .pfx file with the private key and its password.

  1. 1 In Server Manager, select Remote Desktop Services in the left pane. On the Overview tab, under Deployment Overview, select TASKS → Edit Deployment Properties.
  2. 2 Select Certificates. The table lists the role services: RD Gateway, RD Web Access and the two RD Connection Broker role services (Enable Single Sign On and Publishing).
  3. 3 Select a role service, then Select existing certificate. Select Browse, open the .pfx file and enter its password.
  4. 4 Tick Allow the certificate to be added to the Trusted Root Certification Authorities certificate store on the destination computers and select OK.
  5. 5 Select Apply and wait until the certificate has been applied. Repeat steps 3 to 5 for each role service.

In Microsoft's deployment guide, RD Gateway and RD Web Access use the external FQDN and the two RD Connection Broker role services use the Connection Broker's internal FQDN. After a certificate change you may need to restart the TSGateway service on each RD Gateway server yourself. For the RDP listener on the RD Session Host servers, Microsoft refers to the method in subsection 1.

Sources: Use certificates in Remote Desktop Services ↗, Deploy your Remote Desktop environment ↗, Add high availability to the RD Web and Gateway web front ↗ (Microsoft Learn).

3. RD Gateway Manager

Import the certificate on the gateway server in RD Gateway Manager:

  1. 1 In Server Manager, select Remote Desktop Services → Servers. Right-click the server and select RD Gateway Manager.
  2. 2 In the left pane, right-click the gateway name and select Properties.
  3. 3 On the SSL Certificate tab, select Import a certificate into the RD Gateway and then Browse and Import Certificate.
  4. 4 Select the .pfx file, select Open and enter the password. The tab then shows the certificate's details.

Microsoft recommends a publicly issued certificate on RD Gateway, because clients connect from outside. With a certificate from a private CA, every client must trust its chain in advance.

Source: Deploy the Remote Desktop Gateway role ↗ (Microsoft Learn).

4. Set-RDCertificate (PowerShell)

Set-RDCertificate from the RemoteDesktop module imports a certificate, or applies one that is already installed, to an RDS role. Run it in a PowerShell session started as administrator, on a computer with the RDS management tools (RSAT) and the role you are configuring. -Role takes RDGateway, RDWebAccess, RDRedirector or RDPublishing; run the command once for each role you use. Without -ConnectionBroker the cmdlet uses the local computer's FQDN.

Import a .pfx file. Microsoft's example sets RDWebAccess; replace PathToPFXFile with the full path to the file and change Role for the other roles:

$password = Read-Host -AsSecureString -Prompt "Enter Password"
$parameters = @{
  Role        = "RDWebAccess"
  Password    = $password
  ImportPath  = "PathToPFXFile"
}
Set-RDCertificate @parameters

Use a certificate that is already installed (Windows Server 2019 and later). Microsoft's example sets RDRedirector. The certificate must be in LocalMachine\My on every server that runs the role:

Set-RDCertificate -Role RDRedirector -Thumbprint THUMBPRINT -ConnectionBroker "rdcb.internal.com"

Check the result. Get-RDCertificate shows the subject, thumbprint, expiry date and level for each role; a public certificate shows the level Trusted.

Get-RDCertificate -ConnectionBroker "rdcb.internal.com"

Sources: Set-RDCertificate ↗, Get-RDCertificate ↗, Use certificates in Remote Desktop Services ↗ (Microsoft Learn).

GPO distribution (Active Directory)

This section is only relevant if your RDP servers are domain-joined Windows machines in an Active Directory environment. With Group Policy you can configure the RDP listener and NLA requirements centrally:

  1. 1 Open Group Policy Management Console and create a new GPO for RDP servers.
  2. 2 Navigate to Computer Configuration → Administrative Templates → Windows Components → Remote Desktop Services → Remote Desktop Session Host → Security.
  3. 3 Enable Server Authentication Certificate Template and specify the certificate template from your internal CA, or use Require use of specific security layer for remote (RDP) connections set to SSL.
  4. 4 Under Require user authentication for remote connections by using NLA: set to Enabled to require NLA.

An internal CA certificate for RDP servers behind the gateway is a good solution. Distribute the root certificate via GPO to the clients' Trusted Root Certification Authorities store. This way all domain clients automatically trust the RDP servers' certificates.

Hosts file trick: same FQDN for gateway and internal RDP

A common scenario: RD Gateway and the RDP server use the same public FQDN (e.g. rdp.your-domain.com). The client connects to the gateway via public DNS, and the gateway must forward to the internal RDP server. But the gateway cannot resolve rdp.your-domain.com to the internal server, because public DNS points to the gateway itself.

The solution is a hosts file entry on the gateway server:

# C:\Windows\System32\drivers\etc\hosts on the RD Gateway server
10.0.1.50    rdp.your-domain.com

Now the gateway resolves rdp.your-domain.com to the internal IP (10.0.1.50) and forwards RDP traffic correctly. The client only sees rdp.your-domain.com and does not need to know the internal IP.

This approach requires the RDP server to accept connections on the rdp.your-domain.com hostname. If the RDP server uses NLA, its certificate must match rdp.your-domain.com or include it as a SAN. With a wildcard certificate (*.your-domain.com) on both servers this is automatically satisfied.

Troubleshooting

"The remote computer could not be authenticated"

The client does not trust the certificate. Check: (1) Is the certificate chain complete (intermediate + leaf)? (2) Does the hostname in the certificate match the hostname the client is connecting to? (3) Has the certificate expired? Use the SSL Scanner to verify.

RD Gateway: "Your computer can't connect to the remote computer"

Typically a certificate problem on the gateway side. Check that the certificate is bound in RD Gateway Manager (not just IIS). Run Get-Item "RDS:\GatewayServer\SSLCertificate\Thumbprint" in PowerShell to verify. Also ensure the TSGateway service has been restarted after the certificate change.

NLA fails behind gateway

NLA authentication happens between client and RDP server (not the gateway). The client must trust the RDP server's certificate. In a domain environment: distribute the certificate via GPO. Without a domain: import the root certificate manually into the client's Trusted Root store.

Certificate renewed, but gateway still uses the old one

RD Gateway caches the certificate binding. Restart the TSGateway service: Restart-Service TSGateway -Force. Check that the post-renewal script runs correctly by reviewing the log files in simple-acme's log folder.

Certificates on many servers and appliances

A publicly trusted SSL certificate can be valid for at most 199 days now, 99 days by 15 March 2027 and 46 days by 15 March 2029. Each certificate then has to be replaced at least twice a year now and at least eight times a year from 2029, on every server, firewall and load balancer that uses it. sslbrain from FairSSL runs as an appliance in your own network and renews and installs the certificates from one place, including on devices without an agent.

How sslbrain renews and installs certificates on Remote Desktop (RDP)(opens sslbrain.com in a new tab)

Frequently asked questions about RDP and SSL

Find answers to the most common questions about SSL certificates and FairSSL.

Yes, a wildcard certificate (e.g. *.your-domain.com) works well for RD Gateway, RD Web Access and internal RDP connections, as long as all hostnames are under the same domain. It simplifies the setup because one certificate covers everything. However, consider the security implication: if the wildcard key is compromised, all services under the domain are affected.
RD Gateway is an HTTPS proxy that tunnels RDP traffic (port 443). RD Web Access is an IIS web application that displays RemoteApp icons and full-screen desktops in the browser. Both require SSL certificates and typically run on the same server. RD Gateway uses its own certificate store via RD Gateway Manager, while RD Web Access uses IIS HTTPS binding.
Not necessarily. RDP sessions behind the gateway can use internal or self-signed certificates, since the client already has an encrypted connection via the gateway. However, for NLA (Network Level Authentication) the client must trust the RDP server's certificate. In an Active Directory environment you can distribute an internal CA certificate via GPO.
Yes. Use simple-acme with DNS validation and a post-renewal script that binds the new certificate to RD Gateway and IIS. See the simple-acme guide for details on script parameters.
NLA errors are typically caused by the client not trusting the RDP server's certificate. Check: (1) Is the certificate chain complete (intermediate + leaf)? (2) Does the certificate hostname match the name the client is using? (3) Has the certificate expired? (4) In domain environments: is the certificate distributed via GPO to the Personal store on the RDP server?
For RD Gateway, which is exposed to the internet, we recommend OV (Organisation Validation). OV displays the company name in the certificate, giving users confidence that they are connecting to the correct organisation. DV works technically but provides no organisation identification. For internal RDP servers behind the gateway, the certificate type is less important.

Secure your Remote Desktop environment

Create a free account and order your first certificate. A DV certificate is issued in under 2 minutes.