Skip to content

Commit

Permalink
readme: add IPs to self-signed cert
Browse files Browse the repository at this point in the history
re-creating an IPAddress object from the bytes of what is
already and IPAddress object:

[System.Net.IPAddress]::new($_.GetAddressBytes())

is done to get rid of the scope ID on IPv6 addresses.
  • Loading branch information
jantari committed Sep 18, 2024
1 parent 1fc1c2f commit 8eda66a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,19 @@ can generate and trust a new self-signed certificate for testing purposes:
```powershell
# Because we are adding a certificate to the local machine store, this has to be run in an elevated PowerShell session
$IPs = [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces() |
Foreach-Object GetIPProperties |
Foreach-Object UnicastAddresses |
Foreach-Object Address |
Foreach-Object {
"&IPAddress=$( [System.Net.IPAddress]::new($_.GetAddressBytes() ))"
}
[string]$SanIPs = -join $IPs
$SelfSignedCertificateParameters = @{
'DnsName' = 'localhost'
'Subject' = 'localhost'
'TextExtension' = @("2.5.29.17={text}DNS=localhost${SanIPs}")
'NotAfter' = (Get-Date).AddYears(1)
'FriendlyName' = 'rewinged HTTPS'
'KeyAlgorithm' = 'RSA'
Expand Down

0 comments on commit 8eda66a

Please sign in to comment.