Hi,
we want to check URL response of a .asmx URL which needs a client certificate for authenticating.
I got the cert object and then passed it to invoke-webrequest cmdlet, but no matter what i try I always get this error
“The underlying connection was closed”.
code1
$WebClient = New-Object System.Net.WebClient
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$WebClient.DownloadString(“https://server1/mywebservices/myser.asmx”)
code2
$url=”https://server1/mywebservices/myser.asmx”
$cert=(Get-ChildItem cert: -Recurse | where {$_.Thumbprint -eq “abcdefgh3333…..something”}| Select -First 1)
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
#load my client certificate defined by thumbprint
$HTTP_Request = [System.Net.WebRequest]::Create($url)
$HTTP_Request.ClientCertificates.Add($cert )
# We then get a response from the site.
$HTTP_Response = $HTTP_Request.GetResponse()
Can someone please help me.
Thanks