This gist contains instructions for configuring a RDP Device Certificate.
The primary instructions show how to accomplish the task using a MS CA and the GUI.
There are also partially completed steps for accomplishing the same task using powershell.
This gist contains instructions for configuring a RDP Device Certificate.
The primary instructions show how to accomplish the task using a MS CA and the GUI.
There are also partially completed steps for accomplishing the same task using powershell.
| MIT License | |
| Copyright (c) 2022 Taylor Marvin | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is | |
| furnished to do so, subject to the following conditions: | |
| The above copyright notice and this permission notice shall be included in all | |
| copies or substantial portions of the Software. | |
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
| SOFTWARE. |
TODO: Show export using openssl.
$password = 'CertPassword'
$PfxPath = 'C:\Test-Certificate.pfx'
$DerPath = 'C:\Test-Certificate.cer'
$cert = [System.Security.Cryptography.X509Certificates.X509Certificate2]::New($PfxPath, $password, 'DefaultKeySet')
$RootCertRegPath = 'HKLM:\SOFTWARE\Policies\Microsoft\SystemCertificates\Root\Certificates'
$CertRegKeyPath = "$RootCertRegPath\$($cert.Thumbprint)"
$ExistingCert = Get-Item -Path $CertRegKeyPath -ErrorAction Ignore
if ($null -eq $ExistingCert) {
$importPfxCertificateSplat = @{
CertStoreLocation = 'CERT:\LocalMachine\Root'
FilePath = $PfxPath
Password = $password
}
Import-PfxCertificate @importPfxCertificateSplat;
}
$Cert = Get-ChildItem Cert:\LocalMachine\Root\$cert.Thumbprint | Where-Object { $_.Thumbprint -eq $cert.Thumbprint }
Export-Certificate -Cert $cert -FilePath $DerPath$InitGPOSplat = @{
Name = 'TestDeployRootCert'
Comment = 'Deploys the root CA cert to all computers in the domain.'
}
$GPO = new-gpo @InitGPOSplat
$setGPPermissionsSplat = @{
PermissionLevel = 'GpoEdit'
TargetName = 'Domain Admins'
TargetType = 'Group'
}
$TargetDistinguishedName = 'dc=contoso,dc=com' # We're targetting the whole domain here.
$GPO | New-GPLink -Target $TargetDistinguishedName | Set-GPPermissions @setGPPermissionsSplat$DerPath = 'C:\Test-Certificate.cer'
$cert = [System.Security.Cryptography.X509Certificates.X509Certificate2]::New($DerPath)
$setGPPrefRegistryValueSplat = @{
Name = 'TestDeployRootCert'
Context = 'Computer'
Key = "HKLM\SOFTWARE\Policies\Microsoft\SystemCertificates\Root\Certificates\$($cert.Thumbprint)"
ValueName = 'Blob'
Value = Get-Content -Path $DerPath -Raw -AsByteStream
Type = 'Binary'
Action = 'Update'
}
Set-GPPrefRegistryValue @setGPPrefRegistryValueSplatGroup Policy For Steps 5 And 6 (img)
TODO: Need to correlate GP location:
Computer Configuration/Administrative Templates/Windows Components/Remote Desktop Services/Remote Desktop Session Host/Security/Server authentication certificate template
with its registry values.
TODO: Need to correlate GP location:
Computer Configuration/Policies/Windows Setting/Security Settings/Public Key Policies/Certificate Services Client -Auto Enrollment Settings
with its registry values.
This is the consolidated steps from this guide: https://www.pkisolutions.com/creating-rdp-certificates/
JBorean93 was also able to implement RDP device certs strictly using powershell - he did not use an MS CA.
Original pastebin: https://pastebin.com/QXkwd9q4
Contents for posterity:
He noted that this has the advantage of taking effect immediately.