Capturing SSL errors
The ServerCertificateValidationCallback process provides the opportunity to analyze errors during certificate validation.
The method is called asynchronously (in response to an event), therefore the variables created within either the class or script block are not available to PowerShell itself. Information may be exported to a file using a command such as Export-Clixml.
Invoke-WebRequest might throw an error if the validation callback is used. However, if the goal to validate the certificate and response to the web request is less important, System.Net.WebClient might be used.
A number of arguments are passed to the ServerCertificateValidationCallback. The following example provides parameters for each of the arguments: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access