GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Hacker-Scripts/security/local-https-dev-setup.ps1 at master · PowerShellLibrary/Hacker-Scripts

Expand file tree

/

local-https-dev-setup.ps1

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
134 lines (107 loc) · 4.43 KB
/

local-https-dev-setup.ps1

Copy path

File metadata and controls

134 lines (107 loc) · 4.43 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# ---------------------------------------------
# LOCAL HTTPS SETUP FOR DEVELOPMENT
# ---------------------------------------------
$ErrorActionPreference = "Stop"
# --- CONFIG ---
$dns = "localhost"
$port = 19456
$friendlyName = "Dev Local HTTPS Cert"
$storeLocationRoot = "LocalMachine"
$storeNameRoot = "Root"
$storeLocationMy = "LocalMachine"
$storeNameMy = "My"
$prefix = "https://$dns`:$port/"
Write-Host "=============================================="
Write-Host " HTTPS Setup for Local Secure Communication "
Write-Host "=============================================="
Write-Host ""
# Ensure administrator
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Host "[ERROR] This script must be run as Administrator." -ForegroundColor Red
exit 1
}
# ---------------------------------------------
# Step 1 — Check/create certificate
# ---------------------------------------------
Write-Host "🔍 Checking for existing certificate..." -ForegroundColor Cyan
$myStore = New-Object System.Security.Cryptography.X509Certificates.X509Store($storeNameMy, $storeLocationMy)
$myStore.Open("ReadWrite")
$existingCert = $myStore.Certificates | ? { $_.FriendlyName -eq $friendlyName }
if ($existingCert) {
Write-Host "✔ Found existing certificate: $friendlyName" -ForegroundColor Green
$cert = $existingCert
}
else {
Write-Host "⏳ Creating new self-signed certificate for '$dns'..." -ForegroundColor Yellow
$cert = New-SelfSignedCertificate `
-DnsName $dns, "127.0.0.1" `
-FriendlyName $friendlyName `
-CertStoreLocation "Cert:\$storeLocationMy\$storeNameMy" `
-KeyExportPolicy Exportable `
-NotAfter (Get-Date).AddYears(5)
Write-Host "✔ Certificate created successfully!" -ForegroundColor Green
}
$myStore.Close()
# ---------------------------------------------
# Step 2 — Ensure certificate is trusted
# ---------------------------------------------
Write-Host ""
Write-Host "🔐 Ensuring certificate is trusted..." -ForegroundColor Cyan
$rootStore = New-Object System.Security.Cryptography.X509Certificates.X509Store($storeNameRoot, $storeLocationRoot)
$rootStore.Open("ReadWrite")
$alreadyInRoot = $rootStore.Certificates |
Where-Object { $_.Thumbprint -eq $cert.Thumbprint }
if ($alreadyInRoot) {
Write-Host "✔ Certificate already trusted (Root store)." -ForegroundColor Green
}
else {
Write-Host "⏳ Adding certificate to Trusted Root..." -ForegroundColor Yellow
$rootStore.Add($cert)
Write-Host "✔ Certificate trusted successfully!" -ForegroundColor Green
}
$rootStore.Close()
# ---------------------------------------------
# Step 3 — Clean old HTTPS bindings
# ---------------------------------------------
Write-Host ""
Write-Host "🧹 Cleaning old HTTPS bindings on port $port..." -ForegroundColor Cyan
try {
netsh http delete sslcert ipport=0.0.0.0:$port | Out-Null
Write-Host "✔ Old bindings removed." -ForegroundColor Green
}
catch {
Write-Host "ℹ No old bindings found." -ForegroundColor DarkGray
}
# ---------------------------------------------
# Step 4 — Bind certificate to port
# ---------------------------------------------
Write-Host ""
Write-Host "🔗 Binding certificate to port $port..." -ForegroundColor Cyan
$thumb = $cert.Thumbprint
$appid = [guid]::NewGuid()
netsh http add sslcert ipport=0.0.0.0:$port certhash=$thumb certstorename=$storeNameMy appid="{$appid}" | Out-Null
Write-Host "✔ HTTPS binding added successfully!" -ForegroundColor Green
# ---------------------------------------------
# Step 5 — Summary
# ---------------------------------------------
Write-Host ""
Write-Host "=============================================="
Write-Host " SETUP COMPLETE 🎉"
Write-Host "=============================================="
Write-Host ""
Write-Host "🔒 HTTPS is now enabled for your local server."
Write-Host ""
Write-Host "📜 Details:"
Write-Host " - Hostname: $dns"
Write-Host " - Port: $port"
Write-Host " - Prefix: $prefix"
Write-Host " - Thumbprint: $thumb"
Write-Host " - Cert Name: $friendlyName"
Write-Host ""
Write-Host "🧪 Test it in your browser:"
Write-Host " $prefix" -ForegroundColor Yellow
Write-Host ""
Write-Host "✔ Your Chrome extension should now work without certificate errors."
Write-Host ""
Write-Host "=============================================="
Write-Host ""
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.