Configuring Remote Desktop certificates

Configuring Remote Desktop certificates

  • Comments 68

Starting with Windows Server 2003 SP1, it is possible to provide server authentication by issuing a Secure Sockets Layer (SSL) certificate to the Remote Desktop server. This is easy to configure using the “Remote Desktop Session Host Configuration” tool on Server operating systems. Though no such tool is available on Client operating systems such as Windows Vista and Windows 7, it is still possible to provide them with certificates for Remote Desktop connections. There are two possible ways to accomplish this. The first method is using Group Policy and Certificate Templates, and the second one is using a WMI script.

[April 15, 2010: Updated to correct which certificates can be used.]

Part I: Using Group Policy and Certificate Templates.

This method allows you to install Remote Desktop certificates on multiple computers in your domain but it requires your domain to have a working public key infrastructure (PKI).

First, you need to create a Remote Desktop certificate template.

Creating Remote Desktop certificate template:

  1. On the computer that has your enterprise Certification Authority installed start MMC and open the “Certificate Templates” MMC snap-in.
  2. Find the “Computer” template, right-click on it, and then choose “Duplicate Template” from the menu.
  3. In the “Duplicate Template” dialog box, choose “Windows Server 2003 Enterprise” template version.
    clip_image001
  4. The “Properties of New Template” dialog box will appear.
  5. On the “General” page of this dialog box, set both “Template display name” and “Template name” to “RemoteDesktopComputer”. Note: it is important to use the same string for both properties.
  6. On the “Extensions” page, select “Application Policies”, and then click the “Edit…” button.
  7. The “Edit Application Policies Extension” dialog box appears.
    clip_image002
  8. Now you can either remove the “Client Authentication” policy leaving the “Server Authentication” policy, or you can use the special “Remote Desktop Authentication” policy. Doing the latter will prevent certificates based on this template from being used for any purpose other than Remote Desktop authentication.
  9. To create the “Remote Desktop Authentication” policy, first remove both the “Client Authentication” and “Server Authentication” policies, and then click “Add…”
  10. The “Add Application Policy” dialog box appears. In this dialog box click the “New…”
    clip_image003
  11. The “New Application Policy” dialog box appears. In this dialog box, set “Name” to “Remote Desktop Authentication” and “Object Identifier” to “1.3.6.1.4.1.311.54.1.2”, and then click “OK.”
    clip_image004
  12. Select “Remote Desktop Authentication” in the “Add Application Policy” dialog box, and then click “OK.”
  13. Now the “Edit Application Policies Extension” dialog box should look like this:
    clip_image005
  14. Click “OK” in this dialog box, and then click “OK” in the “Properties of New Template” dialog box.

The new template is now ready to use.

The next step is to publish the template.

Publishing the “RemoteDesktopComputer” certificate template:

  1. On the computer that has your enterprise Certification Authority installed, start the Certification Authority MMC snap-in.
  2. Right-click on “Certificate Templates”, then select “New\Certificate Template to Issue” from the menu that appears.
  3. The “Enable Certificate Templates” dialog box appears. Select “RemoteDesktopComputer”, and then click “OK.”

Now the “RemoteDesktopComputer” template is published and can be used in certificate requests.

The last step is to configure Group Policy to use certificates based on the “RemoteDesktopComputer” template for Remote Desktop authentication.

Configuring Group Policy:

Note: The following steps create the new policy to apply to all computers in the domain, but it can also be scoped to an Organizational Unit if needed.

  1. On the domain controller, start the “Group Policy Management” administrative tool.
  2. Right-click the “Default Domain Policy” and click on “Edit…” in the menu that appears. The “Group Policy Management Editor” appears.
  3. Navigate to “Computer Configuration\Policies\Administrative Templates\Windows Components\Remote Desktop Services\Remote Desktop Session Host\Security.”
  4. Double-click the “Server Authentication Certificate Template” policy.
  5. Enable the policy, type “RemoteDesktopComputer” in the “Certificate Template Name” box, and then click “OK.”
    clip_image006
  6. As soon as this policy is propagated to domain computers, every computer that has Remote Desktop connections enabled will automatically request a certificate based on the “RemoteDesktopComputer” template from the Certification Authority server and use it to authenticate to Remote Desktop clients. You can speed up the propagation to a specific computer by running the “gpupdate.exe” command line tool on that computer.

Part II: Using a WMI script.

This method allows you to use a server certificate of your choice with Remote Desktop connections but the certificate needs to be manually installed on the computer first. For example, this method can be used if you bought your certificate from a public certificate authority.

First check that your certificate meets the requirements for Remote Desktop certificates. Certificates that don’t meet these requirements won’t work and will be ignored.

Basic requirements for Remote Desktop certificates:

  1. The certificate is installed into computer’s “Personal” certificate store.
  2. The certificate has a corresponding private key.
  3. The "Enhanced Key Usage" extension has a value of either "Server Authentication" or "Remote Desktop Authentication" (1.3.6.1.4.1.311.54.1.2). Certificates with no "Enhanced Key Usage" extension can be used as well.

In order for a certificate to be used for Remote Desktop connections you first need to obtain the certificate’s thumbprint.

Getting the certificate’s thumbprint:

  1. Double-click on the certificate.
  2. Click the “Details” tab.
  3. Select the “Thumbprint” entry from the list.
    clip_image007
  4. Copy the thumbprint value into Notepad.
  5. Delete all the spaces between the numbers.

Now you have the thumbprint string ready to use. It should look like this: 0e2a9eb75f1afc321790407fa4b130e0e4e223e2

Once you have the thumbprint you can use the following script to cause the certificate to be used for Remote Desktop connections.

WMI script for configuring Remote Desktop certificate:

 

 

var strComputer = ".";

var strNamespace = "\\root\\CIMV2\\TerminalServices";

var wbemChangeFlagUpdateOnly = 1;

var wbemAuthenticationLevelPktPrivacy = 6;


var Locator = new ActiveXObject("WbemScripting.SWbemLocator");


Locator.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy;


var Service = Locator.ConnectServer (strComputer, strNamespace);

var TSSettings = Service.Get("Win32_TSGeneralSetting.TerminalName=\"RDP-Tcp\"");


if (WScript.Arguments.length >= 1 )

{

    TSSettings.SSLCertificateSHA1Hash = WScript.Arguments(0);

}

else

{

     TSSettings.SSLCertificateSHA1Hash = "0000000000000000000000000000000000000000";

}


TSSettings.Put_(wbemChangeFlagUpdateOnly);

To run this sample, copy/paste the above code into a “rdconfig.js” file, start cmd.exe as the Administrator, and then run the following command: “cscript rdconfig.js <thumbprint of your certificate>”. Running this script without a parameter will revert Remote Desktop back to using the default self-signed certificate.

Leave a Comment
  • Please add 3 and 7 and type the answer here:
  • Post
  • After successfully adding thumbprint, attempt to logon with smartcard gives error in Event log:

    "This event indicates an attempt was made to use smartcard logon, but the KDC is unable to use the PKINIT protocol because it is missing a suitable certificate."

    On logon screen i get "System could not log you in. Cannot use smart card logon because smart card logon isn't supported for your user account. Contact your system administrator ....."

    User is member of Remote Desktop Users, certificate has Subject Alt Name set to user@my.domain,

    also has Enhanced Key Usage:

    Client Authentication (1.3.6.1.5.5.7.3.2)

    Server Authentication (1.3.6.1.5.5.7.3.1)

    KDC Authentication (1.3.6.1.5.2.3.5)

    Unknown Key Usage (1.3.6.1.4.1.311.54.1.2)

    Smart Card Logon (1.3.6.1.4.1.311.20.2.2)

    Looks like I'm missing something important :S

    Is installing Terminal Services Role mandatory?

  • Hi Chavdar,

    Are you able to logon locally to the same machine using the same smartcard?

    Answering your question: Installing Terminal Services Role (did you mean Remote Desktop Host role?) is not required in order to use smartcard.

    Thx,

    Sergey.

  • All is running fine :D, looks like I had CRL-accessing problems :(

    Thanks for the support!

  • Thank you for all you've put into this.  Do you know of any way to stop the self signed cert from being re-generated after a reboot?  It appears that I've got everything setup to use my CA cert and I can delete the self signed cert but after a reboot it keeps coming back.  The system is still using the CA cert but the problem we have is that the security scans that we must use keeps picking up the self signed cert and reporting it as a problem.  Any ideas?

  • Hi Tom,

    Unfortunately, there is no way to turn off the self-signed certificate regeneration.

    Thx,

    Sergey.

  • Thanks and as an update, I was mistaken, the security scans don't report the self signed cert as I was expecting it to.  Good to know about the auto self signed generation process.

    Thanks,

  • A revocation check could not be performed for this certificate

    And I can get to URL of the .crl with NO problems at all!

    Using enablecredsspsupport:i:0 as per

    chall32.blogspot.ca/.../fixing-remote-desktop-annoyances.html

    "fixes" it, but that is not really a solution!

    Anybody any ideas?

  • Regarding the question I posted in three years ago, I'm guessing KB2752618 would be the solution.

Page 5 of 5 (68 items) 12345