Firma i file RDP utilizzando il tuo certificato sul lato client
Per semplificare la procedura, sono stati scritti diversi script PowerShell a tua disposizione. Ti preghiamo di modificare i valori delle variabili con i tuoi prima di utilizzarli.
Primo passo
Dovrai prima creare il tuo certificato di firma, con una chiave privata esportabile.
Questo richiede privilegi di amministratore.
Nota che l'impronta digitale del certificato sarà nel lato di configurazione dell'utente.
$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
Secondo passo (sul workstation dell'utente)
Una volta generato il certificato di firma, affinché il tuo cliente possa utilizzarlo, dovrà fare quanto segue:
- importa il certificato nel negozio “CurrentUser\My” per poter firmare i file rdp con rdpsign utilizzando l'impronta del certificato
- importa il certificato nel negozio “CurrentUser\Root” in modo che gli rdp firmati con questo certificato siano riconosciuti
$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
Terzo passo (sul workstation dell'utente)
Per fare in modo che il computer si fidi completamente del file rdp firmato con questo certificato, sarà necessario aggiungerlo nell'elenco delle impronte digitali dei certificati attendibili del registro.
location: “HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows NT\Terminal Services”
chiave: “TrustedCertThumbprints”
tipo: stringa
Nota: poiché scriviamo qui in HKEY_LOCAL_MACHINE, saranno necessari privilegi di amministratore.
$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
Quarto passo (sulla workstation dell'utente)
Infine, per dire al programma “Connection Client” di firmare utilizzando il tuo certificato e firmare con la sua impronta digitale, dovrai impostare la seguente chiave di registro: posizione: “HKEY_CURRENT_USER\Software\Digital River\ConnectionClient”
OPPURE
location: “HKEY_LOCAL_MACHINE\Software\Digital River\ConnectionClient”
chiave: “CertThumbprint”
tipo: stringa
valore: IL_TUO_IMPRONTA_DIGITALE
$thumbprint = "YOUR_THUMBPRINT"New-ItemProperty -Path "HKCU:\Software\Digital River\ConnectionClient" -Name "CertThumbprint" -PropertyType String -Value $thumbprint -Force