- PVSM.RU - https://www.pvsm.ru -
В Сhrome (и практически всех chrome‑подобных браузерах) достаточно давно есть политика CACertificatesWithConstraints, которая, в том числе, позволяет доверять конкретному корневому сертификату только для фиксированного списка доменов. Сам сертификат при этом не требуется размещать в системном корневом хранилище. Это актуально для текущих проблем с отзывами сертификатов и переходом банков на корневой Минцифры https://habr.com/en/news/1066284/ [1]
Ниже простой powershell скрипт для винды и ungoogled‑chromium, в котором необходимо указать:
CertPath — полный локальный путь к сертификату Минцифры (нужен файл russian_trusted_root_ca.cer из архива https://gu‑st.ru/content/lending/android_russian_trusted_root_ca.zip [2])
PermittedDnsNames — массив доменов, для которых сертификат Минцифры разрешён как корневой. Удобно, что политика влияет сразу и на все поддомены указанного домена.
PolicyKey — путь к ветке политик. В примере — путь для chromium, для chrome он, предположительно, HKLM:SOFTWAREPoliciesGoogleChromeCACertificatesWithConstraints
#requires -RunAsAdministrator
$CertPath = '.russian_trusted_root_ca.cer'
$PermittedDnsNames = @('alfabank.ru', 'vtb.ru')
$PolicyKey = 'HKLM:SOFTWAREPoliciesChromiumCACertificatesWithConstraints'
# --- 1. Load cert and emit single-line base64 (handles both PEM and DER input) ---
$cert = [System.Security.Cryptography.X509Certificates.X509Certificate2]::new($CertPath)
$b64 = [Convert]::ToBase64String($cert.RawData)
Write-Host "Subject : $($cert.Subject)"
Write-Host "Issuer : $($cert.Issuer)"
Write-Host "Expires : $($cert.NotAfter)"
if ($cert.Subject -ne $cert.Issuer) {
Write-Warning "Subject != Issuer - this is not a self-signed root. Confirm it's the intended trust anchor."
}
# --- 2. Build the policy entry JSON ---
$obj = [ordered]@{
certificate = $b64
constraints = [ordered]@{
permitted_dns_names = @($PermittedDnsNames)
}
}
$entry = $obj | ConvertTo-Json -Compress -Depth 5
# Guard against PowerShell collapsing a single-element array into a scalar
if ($PermittedDnsNames.Count -eq 1 -and $entry -notmatch '"permitted_dns_names":[') {
$entry = $entry -replace '"permitted_dns_names":("[^"]*")', '"permitted_dns_names":[$1]'
}
# --- 3. Write it ---
New-Item -Path $PolicyKey -Force | Out-Null
Get-Item $PolicyKey | Select-Object -ExpandProperty Property |
ForEach-Object { Remove-ItemProperty -Path $PolicyKey -Name $_ } # clear stale entries
New-ItemProperty -Path $PolicyKey -Name '1' -Value $entry -PropertyType String -Force | Out-Null
Write-Host "`nWrote to $PolicyKey value '1':"
Write-Host $entry
После прогона скрипта, достаточно сделать Reload policies в chrome://policy/ и убедиться, что политика появилась со статусом OK.
Автор: Pavel7
Источник [3]
Сайт-источник PVSM.RU: https://www.pvsm.ru
Путь до страницы источника: https://www.pvsm.ru/mintsifry/456049
Ссылки в тексте:
[1] https://habr.com/en/news/1066284/: https://habr.com/en/news/1066284/
[2] https://gu‑st.ru/content/lending/android_russian_trusted_root_ca.zip: https://gu-st.ru/content/lending/android_russian_trusted_root_ca.zip
[3] Источник: https://habr.com/ru/articles/1066372/?utm_source=habrahabr&utm_medium=rss&utm_campaign=1066372
Нажмите здесь для печати.