groups: AI enhance for gallery photos (photo_jobs.group_photo_id, before/after compare modal)
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
# Script: install-whatido-cert.ps1
|
||||
# Назначение: скачивает самоподписанный сертификат WhatIDo и импортирует его в
|
||||
# локальное хранилище "Доверенные корневые центры сертификации" (LocalMachine\Root).
|
||||
# После перезапуска браузера (или повторного подключения) предупреждение о
|
||||
# самоподписанном сертификате исчезает.
|
||||
#
|
||||
# Запуск (от имени администратора):
|
||||
# .\install-whatido-cert.ps1
|
||||
#
|
||||
# Или удаленно / по URL:
|
||||
# .\install-whatido-cert.ps1 -Url 'http://192.168.88.100:3003/certs/cert.pem'
|
||||
|
||||
param(
|
||||
[ValidateSet('LocalMachine', 'CurrentUser', IgnoresCase = $false)]
|
||||
[string] $StoreLocation = 'LocalMachine',
|
||||
|
||||
[string] $CertUrl = 'http://127.0.0.1:3003/certs/cert.pem'
|
||||
)
|
||||
|
||||
# Путь, куда временно сохранится сертификат
|
||||
$TempCert = [System.IO.Path]::GetTempFileName() + '.cer'
|
||||
trap {
|
||||
if (Test-Path $TempCert) { Remove-Item -Force $TempCert -ErrorAction SilentlyContinue }
|
||||
}
|
||||
|
||||
# --- 1. Скачиваем сертификат ---
|
||||
Write-Host "Скачивание сертификата из: $CertUrl" -ForegroundColor Cyan
|
||||
|
||||
try {
|
||||
$bytes = Invoke-WebRequest -Uri $CertUrl -UseBasicParsing -TimeoutSec 30 -ErrorAction Stop
|
||||
$bytes.Content | Out-File -FilePath $TempCert -Encoding Byte -Force
|
||||
Write-Host "Сертификат сохранён во временный файл: $TempCert" -ForegroundColor Green
|
||||
}
|
||||
catch {
|
||||
Write-Error "Не удалось скачать сертификат: $_"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# --- 2. Проверяем, что файл — это X.509 сертификат ---
|
||||
$certContent = [System.IO.File]::ReadAllBytes($TempCert)
|
||||
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($certContent)
|
||||
|
||||
Write-Host "Сертификат: $($cert.Subject)" -ForegroundColor Yellow
|
||||
Write-Host "Выдан: $($cert.Issuer)" -ForegroundColor Yellow
|
||||
Write-Host "Срок действия: от $($cert.NotBefore) до $($cert.NotAfter)" -ForegroundColor Yellow
|
||||
Write-Host "Кол-во IP в SAN: $($cert.Extensions | Where-Object { $_.Oid.FriendlyName -eq 'Subject Alternative Name' } | ForEach-Object { $_.Format($true) -split ',' } | Measure-Object). IP-адресов в сертификате" -ForegroundColor Yellow
|
||||
|
||||
if ($cert.Subject -notmatch 'whatido') {
|
||||
Write-Warning "Тема сертификата '$($cert.Subject)' отличается от ожидаемой ('CN=whatido.local')."
|
||||
$continue = Read-Host "Продолжить установку? (y/n)"
|
||||
if ($continue -ne 'y' -and $continue -ne 'Y') { exit 0 }
|
||||
}
|
||||
|
||||
# --- 3. Проверяем, есть ли уже такой сертификат в хранилище ---
|
||||
$storePath = "Cert:\$StoreLocation\Root"
|
||||
if (!(Test-Path $storePath)) {
|
||||
Write-Error "Хранилище не найдено: $storePath"
|
||||
exit 1
|
||||
}
|
||||
|
||||
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store('Root', $StoreLocation)
|
||||
$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite)
|
||||
|
||||
$existing = $store.Certificates | Where-Object {
|
||||
$_.Thumbprint -eq $cert.Thumbprint -or $_.Thumbprint -eq $cert.Thumbprint.ToUpperInvariant()
|
||||
}
|
||||
|
||||
if ($existing) {
|
||||
Write-Host "Сертификат уже установлен в хранилище $storePath" -ForegroundColor Green
|
||||
$store.Close()
|
||||
exit 0
|
||||
}
|
||||
|
||||
# --- 4. Импортируем в хранилище корневых сертификатов ---
|
||||
Write-Host "Импортируем сертификат в: $storePath" -ForegroundColor Cyan
|
||||
|
||||
$store.Add($cert)
|
||||
Write-Host "Успешно: сертификат добавлен в хранилище 'Доверенные корневые центры сертификации' ($StoreLocation)" -ForegroundColor Green
|
||||
|
||||
# --- 5. Показываем итоговое содержимое (для подтверждения) ---
|
||||
Write-Host "Теперь в хранилище:" -ForegroundColor Cyan
|
||||
$store.Certificates | Where-Object { $_.NotAfter -gt (Get-Date) -and $_.Subject -match 'whatido' } |
|
||||
Select-Object -First 5 Subject, NotAfter, Thumbprint | Format-Table -AutoSize
|
||||
|
||||
$store.Close()
|
||||
|
||||
# --- 6. Очистка ---
|
||||
Remove-Item -Force $TempCert -ErrorAction SilentlyContinue
|
||||
Write-Host "Временный файл удалён." -ForegroundColor Gray
|
||||
Reference in New Issue
Block a user