クライアント側で独自の証明書を使用してRDPファイルに署名する
手続きを簡素化するために、複数のPowerShellスクリプトがあなたのために作成されました。使用する前に、変数の値を自分のものに変更してください。
最初のステップ
最初に、エクスポート可能な秘密鍵を持つ独自の署名証明書を作成する必要があります。
これには管理者権限が必要です。
証明書の指紋はユーザー設定側に表示されます。
$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
ユーザーのワークステーションでの第二ステップ
署名証明書が生成されたら、クライアントがそれを使用するためには、次のことを行う必要があります。
- 証明書のサムプリントを使用してrdpファイルに署名するために、「CurrentUser\My」ストアに証明書をインポートします。
- 「CurrentUser\Root」ストアに証明書をインポートして、この証明書で署名されたRDPが認識されるようにします。
$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
ユーザーのワークステーションでの第三ステップ
この証明書で署名されたrdpファイルをコンピュータが完全に信頼するようにするには、レジストリの信頼された証明書サムプリントリストに追加する必要があります。
location: “HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows NT\Terminal Services”
キー: “TrustedCertThumbprints”
タイプ: 文字列
注意: ここで HKEY_LOCAL_MACHINE に書き込むため、管理者権限が必要です。
$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
ユーザー作業ステーションでの第四ステップ
最後に、「Connection Client」プログラムにあなたの証明書を使用して署名し、その指紋で署名するように指示するには、次のレジストリキーを設定する必要があります:
場所: “HKEY_CURRENT_USER\Software\Digital River\ConnectionClient”
または
location: “HKEY_LOCAL_MACHINE\Software\Digital River\ConnectionClient”
キー: “CertThumbprint”
タイプ: 文字列
値: あなたの指紋
$thumbprint = "YOUR_THUMBPRINT"New-ItemProperty -Path "HKCU:\Software\Digital River\ConnectionClient" -Name "CertThumbprint" -PropertyType String -Value $thumbprint -Force