Firma archivos RDP utilizando tu propio certificado en el lado del cliente
Para simplificar el procedimiento, se han escrito múltiples scripts de PowerShell a su disposición. Por favor, cambie los valores de las variables por los suyos propios antes de usarlos.
Primer paso
Primero necesitarás crear tu propio certificado de firma, con una clave privada exportable.
Esto requiere privilegios de administrador.
Tenga en cuenta que la huella digital del certificado estará en el lado de configuración del usuario.
$organization = "MyCompany"$commonName = "RDP Signer"$friendlyName = "RDP Signing Certificate"$pfxPassword = "MyStrongPassword!"$pfxFilePath = [Environment]::CurrentDirectory + "\signer.pfx"# In years$validityDuration = 3
Write-Host Certificate will be created in $pfxFilePath
# Generate the signing certificate$cert = New-SelfSignedCertificate ` -Type CodeSigningCert ` -Subject "CN=$commonName, O=$organization" ` -KeyUsage DigitalSignature ` -KeyExportPolicy Exportable ` -FriendlyName $friendlyName ` -CertStoreLocation "Cert:\LocalMachine\My" ` -NotAfter (Get-Date).AddYears($validityDuration)
# Generate the pfx file to import on client computer$thumb = $cert.Thumbprint
Write-Host Certificate thumbprint: $thumb
$pwd = ConvertTo-SecureString -String $pfxPassword -Force -AsPlainTextGet-ChildItem -Path Cert:\LocalMachine\My\$thumb | Export-PfxCertificate -FilePath "$pfxFilePath" -Password $pwd
Segundo paso (En la estación de trabajo del usuario)
Una vez que se genere el certificado de firma, para que su cliente pueda utilizarlo, deberá hacer lo siguiente:
- importar el certificado en la tienda “CurrentUser\My” para poder firmar archivos rdp con rdpsign utilizando la huella digital del certificado
- importar el certificado en el almacén “CurrentUser\Root” para que los rdp firmados con este certificado sean reconocidos
$pfxFilePath = [Environment]::CurrentDirectory + "\signer.pfx"$pfxPassword = "MyStrongPassword!"
$pwd = ConvertTo-SecureString -String $pfxPassword -Force -AsPlainText
# Import pfx in CurrentUser\My certificate store to be able to sign with rdpsign using the thumbprintImport-PfxCertificate -FilePath "$pfxFilePath" -CertStoreLocation "Cert:\CurrentUser\My" -Password $pwd
# Import pfx to the trusted root certificate authority of the user, so that signed rdp with this certificate are recognized.# Note: this triggers a windows confirmation popupImport-PfxCertificate -FilePath "$pfxFilePath" -CertStoreLocation "Cert:\CurrentUser\Root" -Password $pwd
Tercer paso (En el puesto de trabajo del usuario)
Para que el ordenador confíe completamente en el archivo rdp firmado con este certificado, necesitarás añadirlo a la lista de huellas digitales de certificados de confianza en el registro.
location: “HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows NT\Terminal Services”
clave: “TrustedCertThumbprints”
tipo: cadena
Nota: dado que escribimos aquí en HKEY_LOCAL_MACHINE, se necesitarán privilegios de administrador.
$thumbprint = "YOUR_THUMBPRINT"
$regPath = "HKLM:\Software\Policies\Microsoft\Windows NT\Terminal Services"$keyName = "TrustedCertThumbprints"
$current = (Get-ItemProperty -Path $regPath -Name $keyName -ErrorAction SilentlyContinue).$keyName$newValue = if ([string]::IsNullOrWhiteSpace($current)) { $thumbprint } else { "$current,$thumbprint" }
New-Item -Path $regPath -Force | Out-NullNew-ItemProperty -Path $regPath -Name $keyName -Value $newValue -PropertyType String -Force | Out-Null
Cuarta etapa (en el puesto de trabajo del usuario)
Finalmente, para indicarle al programa “Connection Client” que firme utilizando su certificado y firme con su huella digital, necesitará establecer la siguiente clave del registro: ubicación: “HKEY_CURRENT_USER\Software\Digital River\ConnectionClient”
O bien
location: “HKEY_LOCAL_MACHINE\Software\Digital River\ConnectionClient”
clave: “CertThumbprint”
tipo: cadena
valor: TU_HUELLADIGITAL
$thumbprint = "YOUR_THUMBPRINT"New-ItemProperty -Path "HKCU:\Software\Digital River\ConnectionClient" -Name "CertThumbprint" -PropertyType String -Value $thumbprint -Force