قم بتوقيع ملفات 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
الخطوة الثانية (على محطة عمل المستخدم)
بمجرد إنشاء شهادة التوقيع، لكي يتمكن عميلك من استخدامها، سيتعين عليهم القيام بما يلي:
- استيراد الشهادة في مخزن "CurrentUser\My" لتكون قادرًا على توقيع ملفات rdp باستخدام rdpsign باستخدام بصمة الشهادة.
- استيراد الشهادة في مخزن "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 الموقّع بهذا الشهادة، ستحتاج إلى إضافته في قائمة بصمات الشهادات الموثوقة في السجل.
الموقع: "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"
أو
الموقع: “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