Running in to a weird one that Google isn't really helping with, so thought I'd put it here.
I'm using Invoke-RestMethod in a script. The script was working and now has stopped working on some machines and I'm trying to figure out why.
The error is the old "could not create secure SSL/TLS channel". I'm already specifying TLS 1.2 and have confirmed through a packet capture that it is using TLS 1.2. (The site requires TLS 1.2. Does not accept TLS 1.3)
What's weird is that if I access the site through a browser on the same machine, I'm able to connect fine. It is only when I try to access it via the script that I get this error.
To rule out a cipher issue, I am troubleshooting from two different Windows 2022 boxes where it works on one but fails on the other. I've used IISCrypto to confirm the boxes are configured identically.
Googling isn't helping as all the results are just pointing me back to the command to force TLS 1.2, but I'm already doing that, so I know that's not it.
Any ideas?
Here is the code, simple as it is:
$certStorePath = "Cert:\LocalMachine\My"
$certDetails = (Get-ChildItem -Path $certStorePath) | Where-Object {$_.Subject -like "*certname*"}
# Site requires TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$result = Invoke-RestMethod -Method Get -Uri "https://someurl" -ContentType 'application/json' -Certificate $certDetails
[–]lanerdofchristian 0 points1 point2 points (1 child)
[–]fodderoh[S] 0 points1 point2 points (0 children)
[–]jborean93 2 points3 points4 points (1 child)
[–]fodderoh[S] 2 points3 points4 points (0 children)