Vjz
Vjz

Reputation: 121

Invoke-WebRequest only works once in a PowerShell 5.1 Instance against Pode HTTP Server Instance

I am using Invoke-WebRequest with a Client Certificate against a Pode HTTPS server instance (See this GitHub issue for its implementation, running on Windows Server 2019) in a Windows PowerShell 5.1.19041.1645 instance (.NET Framework 4.8.04084, running on Windows 10) running as Administrator but it will only work once successfully in that instance, all subsequent invocations/requests will result in a timeout:

$Certificate = Get-ChildItem -Path Cert:\LocalMachine\My | Where-Object { $_.Thumbprint -eq 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' } # As Administrator
Invoke-WebRequest -Uri 'https://api.example.com/api/v1.0/test' -Certificate $Certificate -TimeoutSec 10

-however, if I run this in PowerShell 7.2.2 it will function correctly on the first and subsequent invocations.

Other things of note:

I'm assuming this is due to some implementation difference between .NET Framework 4.8 and .NET 6.0 that's incompatible with this HTTPS server? It seems Pode has it's own HTTP Implementation (PodeHttpRequest.cs) and deals with TLS via use of SslStream (PodeRequest.cs) so maybe there is a Pode bug?

How do I fix or mitigate this? Is this issue on the client-side or server-side? My configuration or a bug?

Upvotes: 1

Views: 637

Answers (0)

Related Questions