feat(tls): issue server certificate from internal root CA

Generate a 10-year root CA in entrypoint.sh and sign the server leaf with it. Only the root CA is distributed to clients (including GPO); the leaf is served by the app and is reissued automatically when CERT_HOSTNAMES changes. Update the Windows installer, ZIP package, settings UI and docs for the two-tier scheme.
This commit is contained in:
dev
2026-10-22 18:09:30 +03:00
parent b5eeb5fbdf
commit ba32234217
9 changed files with 272 additions and 122 deletions
+19 -11
View File
@@ -1,5 +1,5 @@
# Script: install-whatido-cert.ps1
# Импортирует самоподписанный сертификат WhatIDo в локальное хранилище
# Импортирует корневой сертификат WhatIDo в локальное хранилище
# "Доверенные корневые центры сертификации" (Root), чтобы браузер перестал
# показывать предупреждение о небезопасном подключении.
#
@@ -17,7 +17,7 @@ param(
[string] $CertPath = '',
[string] $CertUrl = 'http://127.0.0.1:3003/certs/cert.pem',
[string] $CertUrl = 'http://127.0.0.1:3003/certs/root-ca.pem',
[string] $CheckHost = '',
@@ -82,7 +82,7 @@ if ($CertPath) {
} else {
$here = $PSScriptRoot
if (-not $here) { $here = Split-Path -Parent $MyInvocation.MyCommand.Path }
foreach ($name in @('whatido-cert.cer', 'whatido-cert.pem', 'cert.pem')) {
foreach ($name in @('whatido-root-ca.cer', 'whatido-root-ca.pem', 'whatido-cert.cer', 'whatido-cert.pem', 'cert.pem')) {
$candidate = Join-Path $here $name
if (Test-Path $candidate) {
$bytes = [System.IO.File]::ReadAllBytes($candidate)
@@ -128,20 +128,28 @@ Write-Host "Срок: $($cert.NotBefore) - $($cert.NotAfter)" -ForegroundCol
Write-Host "Отпечаток: $($cert.Thumbprint)" -ForegroundColor DarkGray
$san = @(Get-SanValues $cert)
Write-Host "Адреса в сертификате: $($san.Count)" -ForegroundColor Yellow
foreach ($s in ($san | Select-Object -First 12)) { Write-Host " $s" -ForegroundColor DarkGray }
if ($san.Count -gt 12) { Write-Host " ... и ещё $($san.Count - 12)" -ForegroundColor DarkGray }
if ($san.Count -gt 0) {
Write-Host "Адреса в сертификате: $($san.Count)" -ForegroundColor Yellow
foreach ($s in ($san | Select-Object -First 12)) { Write-Host " $s" -ForegroundColor DarkGray }
if ($san.Count -gt 12) { Write-Host " ... и ещё $($san.Count - 12)" -ForegroundColor DarkGray }
} else {
Write-Host "Это корневой сертификат: списка адресов у него нет." -ForegroundColor DarkGray
}
if ($cert.Subject -match 'whatido' -and $cert.Issuer -ne $cert.Subject) {
Write-Warning "Сертификат выпущен не самим собой. Продолжайте, только если доверяете его издателю."
}
if ($CheckHost) {
$hit = Get-HostInSan $cert $CheckHost
if ($hit) {
Write-Host "Адрес $CheckHost покрыт сертификатом ($hit) - предупреждение браузера исчезнет." -ForegroundColor Green
if ($san.Count -eq 0) {
Write-Host "В этом сертификате нет списка адресов: это корневой CA. Адреса сервера смотрите в whatido-server.pem или в разделе «Сертификат» настроек." -ForegroundColor DarkGray
} else {
Write-Warning "Адрес $CheckHost НЕ входит в сертификат. После установки предупреждение останется. Добавьте адрес в CERT_HOSTNAMES в .env и пересоздайте сертификат."
$hit = Get-HostInSan $cert $CheckHost
if ($hit) {
Write-Host "Адрес $CheckHost покрыт сертификатом ($hit) - предупреждение браузера исчезнет." -ForegroundColor Green
} else {
Write-Warning "Адрес $CheckHost НЕ входит в сертификат. После установки предупреждение останется. Добавьте адрес в CERT_HOSTNAMES в .env и пересоздайте сертификат."
}
}
}
@@ -193,7 +201,7 @@ try {
exit 1
}
Write-Host "Сертификат добавлен в хранилище $storePath" -ForegroundColor Green
Write-Host "Корневой сертификат добавлен в хранилище $storePath" -ForegroundColor Green
# --- 5. Проверка цепочки ---
if (Test-CertTrusted $cert) {