Configuring RestPS to use HTTPS

My good friend Mikael Nystrom recently posted a guide on how to setup the RestPS PowerShell Framework to run as as service via NSSM – the Non-Sucking Service Manager. In case you missed that post, you can find it here: Nice to Know – Running RestPS as a Service.

Anyway, the default configuration of RestPS is to use HTTP, and I wanted to use HTTPS to improve security. Here is a quick guide on doing that. In this guide I'm assuming you have a web server certificate already installed on the server you are running RestPS on.

Configure the RestPS start script to use HTTPS

In this example, my web server certificate I used for my RestPS server had a friendly name set to "PSD", so I simply used that one when getting the thumbprint. Here is a RestPS start script that is configured to start RestPS in HTTPS.

Start-Transcript -Path E:\Scripts\RestPS\Start.log 
Set-Location -Path E:\Scripts\RestPS -Verbose
Import-Module RESTPS -Force

$ServerCert = Get-ChildItem Cert:\LocalMachine\My | Where-Object {$_.FriendlyName -eq "PSD"}

$ServerParams = @{
    RoutesFilePath = 'E:\RestPS\endpoints\RestPSRoutes.json'
    Port = 8080
    SSLThumbprint = $ServerCert.Thumbprint
    AppGuid = '12345678-db90-4b66-8b01-88f7af2e36cf'
    VerificationType = 'VerifyRootCA'
    Logfile = 'E:\Scripts\RestPS\RestPS.log'
    LogLevel = 'ALL'
    RestPSLocalRoot = 'E:\RestPS'
}
Start-RestPSListener @ServerParams

Stop-Transcript -Path E:\Scripts\RestPS\Start.log 
The RestPS log file showing its listening on HTTPS.
About the author

Johan Arwidmark

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

>