-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-certs.ps1
More file actions
38 lines (32 loc) · 1.36 KB
/
Copy pathgenerate-certs.ps1
File metadata and controls
38 lines (32 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Generate self-signed SSL certificate for n8n HTTPS
# Run from project root: .\generate-certs.ps1
$certsDir = Join-Path $PSScriptRoot "certs"
$certPath = Join-Path $certsDir "cert.pem"
$keyPath = Join-Path $certsDir "key.pem"
if (-not (Test-Path $certsDir)) {
New-Item -ItemType Directory -Path $certsDir | Out-Null
}
# Find OpenSSL (PATH, or Git for Windows)
$openssl = Get-Command openssl -ErrorAction SilentlyContinue
if (-not $openssl) {
$gitPaths = @(
"$env:ProgramFiles\Git\usr\bin\openssl.exe",
"${env:ProgramFiles(x86)}\Git\usr\bin\openssl.exe"
)
foreach ($p in $gitPaths) {
if (Test-Path $p) { $openssl = $p; break }
}
}
$opensslExe = if ($openssl -is [string]) { $openssl } elseif ($openssl) { $openssl.Source } else { $null }
if (-not $opensslExe) {
Write-Host "OpenSSL not found." -ForegroundColor Red
Write-Host "Options:" -ForegroundColor Yellow
Write-Host " 1. Install Git for Windows (https://git-scm.com) - includes OpenSSL, then run again"
Write-Host " 2. Install OpenSSL (https://slproweb.com/products/Win32OpenSSL.html)"
Write-Host " 3. Use WSL or run generate-certs.sh in Git Bash"
exit 1
}
& $opensslExe req -x509 -nodes -days 365 -newkey rsa:2048 `
-keyout $keyPath -out $certPath `
-subj "/CN=localhost"
Write-Host "Done! Created cert.pem and key.pem in certs/" -ForegroundColor Green