Skip to content

Commit

Permalink
Add Certificates section
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyPhipps committed Nov 13, 2024
1 parent 1907dcb commit 6ea1a7d
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions Products/powershell.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,25 @@ Make a parameter mandatory
...
```

# Certificates

Skip certificate validation checks (use only for known-good self-signed certs)
```ps
# Trust all certificates (use if self-signed cert is being used
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
```


# Misc
Convert .json file to PowerShell objects
Expand Down Expand Up @@ -273,21 +292,3 @@ foreach ($key in $newProperties.Keys) {
$myObject | Add-Member -MemberType NoteProperty -Name $key -Value $newProperties[$key]
}
```


Skip certificate validation checks (use only for known-good self-signed certs)
```ps
# Trust all certificates (use if self-signed cert is being used
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
```

0 comments on commit 6ea1a7d

Please sign in to comment.