UDRestAPI -Certificate not working

If i don’t use a certificate at all, it works for HTTP just fine. I tried 3 different certificates. I tried using a 2012 r2 and 2016 server. I tried using ports 591, 8008, 8080 and 9090 in place of 10001. I thought it could’ve been PowerShell so i prefixed it with

$Client = New-Object -TypeName System.Net.WebClient
$Client.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12

Running version 2.7 I get these errors
HTTPS Invoke-RestMethod : The underlying connection was closed: An unexpected error occurred on a send.
HTTP Invoke-RestMethod : The remote server returned an error: (500) Internal Server Error.

Running version 2.6.2 doesn’t help either.
HTTPS Invoke-RestMethod : The underlying connection was closed: An unexpected error occurred on a send.
HTTP Invoke-RestMethod : The underlying connection was closed: The connection was closed unexpectedly.

Script

Get-UDRestApi | Stop-UDRestApi

$Endpoint = New-UDEndpoint -Url “/HelloWorld” -Endpoint {
“HelloWorld - it really works!”
}

$Cert = ( Get-ChildItem Cert:\LocalMachine\My\CERTNUMBA1 )
#$Cert = ( Get-ChildItem Cert:\LocalMachine\my\CERTNUMBA2 )
#$Cert = ( Get-ChildItem Cert:\LocalMachine\my\CERTNUMBA3 )

Write-Host "Started? " -NoNewline
$RESTAPI = Start-UDRestApi -Name HelloWorld -Endpoint $Endpoint -Port 10001 -Certificate $Cert
$RESTAPI.Running

start-sleep -seconds 5

Write-Host “Trying HTTPS”
Invoke-RestMethod -Method Get -Uri https://localhost:10001/api/HelloWorld

Write-Host “Trying HTTP”
Invoke-RestMethod -Method Get -Uri http://localhost:10001/api/HelloWorld

1 Like

Bug in 2.7. It’s fixed in the 2.8 nightly releases.