Skip to content

Commit ed39028

Browse files
committed
✨ Trace-WebRequest.ps1 should add certificate details
- resolves brianary#65
1 parent 76dec0d commit ed39028

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

Trace-WebRequest.ps1

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,20 @@ Import-Variables.ps1
2323
.EXAMPLE
2424
Trace-WebRequest.ps1 g.co/p3phelp -SkipHeaders -SkipContent
2525
26+
g.co is CN=*.google.com from CN=WR2, O=Google Trust Services, C=US
27+
Valid 05/12/2025 01:42:58 to 08/04/2025 01:42:57
2628
GET https://g.co/p3phelp
27-
HTTP/1.1 302 Found
29+
HTTP/1.1 302 Found
2830
Following redirect to https://support.google.com/accounts/answer/151657?hl=en
31+
support.google.com is CN=*.google.com from CN=WR2, O=Google Trust Services, C=US
32+
Valid 05/12/2025 01:42:58 to 08/04/2025 01:42:57
2933
GET https://support.google.com/accounts/answer/151657?hl=en
30-
HTTP/1.1 301 MovedPermanently
31-
Following redirect to https://support.google.com/accounts/topic/3382252?hl=en&visit_id=638822697229889622-2656653887&rd=1
32-
GET https://support.google.com/accounts/topic/3382252?hl=en&visit_id=638822697229889622-2656653887&rd=1
33-
HTTP/1.1 301 MovedPermanently
34-
Following redirect to https://support.google.com/accounts/?hl=en&visit_id=638822697229889622-2656653887&rd=2&topic=3382252
35-
GET https://support.google.com/accounts/?hl=en&visit_id=638822697229889622-2656653887&rd=2&topic=3382252
34+
HTTP/1.1 301 MovedPermanently
35+
Following redirect to https://support.google.com/accounts/topic/3382252?hl=en&visit_id=638845176026805186-2907418293&rd=1
36+
GET https://support.google.com/accounts/topic/3382252?hl=en&visit_id=638845176026805186-2907418293&rd=1
37+
HTTP/1.1 301 MovedPermanently
38+
Following redirect to https://support.google.com/accounts/?hl=en&visit_id=638845176026805186-2907418293&rd=2&topic=3382252
39+
GET https://support.google.com/accounts/?hl=en&visit_id=638845176026805186-2907418293&rd=2&topic=3382252
3640
HTTP/1.1 200 OK
3741
#>
3842

@@ -53,7 +57,8 @@ using namespace System.Net.Http
5357
)
5458
Begin
5559
{
56-
Import-CharConstants.ps1 :outbox_tray: :inbox_tray: :information_source: -AsEmoji
60+
$certhost = @{}
61+
Import-CharConstants.ps1 :lock: :outbox_tray: :inbox_tray: :information_source: 'timer clock' -AsEmoji
5762

5863
filter Get-HttpStatusColor
5964
{
@@ -79,6 +84,13 @@ Begin
7984
# The HTTP method verb to use.
8085
[HttpMethod] $Method = 'GET'
8186
)
87+
if(!$certhost.Contains($Uri.Host))
88+
{
89+
$certinfo = Get-ServerCertificate.ps1 $Uri.Host
90+
$certhost[$Uri.Host] = $certinfo
91+
Write-Info.ps1 "$lock $($Uri.Host) is $($certinfo.Subject) from $($certinfo.Issuer)" -fg Magenta
92+
Write-Info.ps1 "${timer clock} Valid $($certinfo.Issued) to $($certinfo.Expires)" -fg DarkMagenta
93+
}
8294
$request = New-Object Net.Http.HttpRequestMessage -ArgumentList $Method, $Uri
8395
$requestLine, $requestRawHeaders = "$Method $Uri", ($request.Headers.ToString())
8496
Write-Verbose $requestLine

0 commit comments

Comments
 (0)