Skip to content

Commit 0f0f01a

Browse files
committed
docs: tighten network TLS diagnostics
1 parent 8b33f43 commit 0f0f01a

1 file changed

Lines changed: 28 additions & 19 deletions

File tree

rules/network-troubleshoot.mdc

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ Use this rule as a concise decision guide for developer network failures. Keep d
1313
- Prefer read-only diagnostics and trusted project-provided diagnostic scripts.
1414
- Use the failing host, URL, registry, or service as the default probe target.
1515
- Ask before probing unrelated external services.
16-
- Do not print proxy URLs, credentials, tokens, auth headers, package index URLs, registry hostnames from config, or raw config values.
17-
- When sharing output, redact internal hosts and URLs unless the user explicitly approves including them.
16+
- Do not print proxy URLs, credentials, tokens, auth headers, package index URLs, registry hostnames from config, or raw config values in shared output.
17+
- Internal hosts and URLs may be collected and used for target-scoped local diagnostics, but redact them before sharing logs or reports unless the user explicitly approves including them.
1818
- Do not dump local config from npm, pnpm, yarn, pip, Git, Docker, shell, OS proxy, VPN, or certificate stores.
1919
- Do not disable, bypass, or skip TLS or certificate verification.
2020
- Do not change OS networking, DNS, proxy, package manager, Git, Docker, shell, VPN, or trust-store settings without explicit user approval for the exact action.
@@ -109,35 +109,44 @@ Linux/macOS:
109109

110110
```bash
111111
openssl s_client -connect <target-host>:<port> -servername <target-host> -showcerts </dev/null
112-
echo | openssl s_client -connect <target-host>:<port> -servername <target-host> 2>/dev/null | openssl x509 -noout -dates
112+
echo | openssl s_client -connect <target-host>:<port> -servername <target-host> 2>/dev/null | openssl x509 -noout -subject -issuer -dates
113113
```
114114

115115
Windows PowerShell:
116116

117117
```powershell
118-
$uri = "https://<target-host>:<port>/<path>"
119-
$req = [Net.HttpWebRequest]::Create($uri)
120-
$req.Method = "HEAD"
121-
$req.Timeout = 5000
122118
try {
123-
$resp = $req.GetResponse()
124-
"HTTP status: $([int]$resp.StatusCode)"
125-
$resp.Close()
126-
} catch [Net.WebException] {
127-
if ($_.Exception.Response) {
128-
"HTTP status: $([int]$_.Exception.Response.StatusCode)"
129-
$_.Exception.Response.Close()
130-
} else {
131-
"TLS or connection error: $($_.Exception.Message)"
119+
$req = [Net.HttpWebRequest]::Create("https://<target-host>:<port>/<path>")
120+
$req.Method = "HEAD"
121+
$req.Timeout = 5000
122+
123+
try {
124+
$resp = $req.GetResponse()
125+
} catch [Net.WebException] {
126+
$resp = $_.Exception.Response
127+
if ($req.ServicePoint.Certificate) {
128+
$cert = $req.ServicePoint.Certificate
129+
"Cert subject: $($cert.Subject)"
130+
"Cert expires: $($cert.GetExpirationDateString())"
131+
}
132+
if ($resp) {
133+
"HTTP status: $([int]$resp.StatusCode) $($resp.StatusDescription)"
134+
$resp.Close()
135+
} else {
136+
"TLS/network error: $($_.Exception.Message)"
137+
}
138+
return
132139
}
133-
} catch {
134-
"TLS or connection error: $_"
135-
} finally {
140+
136141
$cert = $req.ServicePoint.Certificate
137142
if ($cert) {
138143
"Cert subject: $($cert.Subject)"
139144
"Cert expires: $($cert.GetExpirationDateString())"
140145
}
146+
"HTTP status: $([int]$resp.StatusCode) $($resp.StatusDescription)"
147+
$resp.Close()
148+
} catch {
149+
"TLS/network error: $($_.Exception.Message)"
141150
}
142151
```
143152

0 commit comments

Comments
 (0)