Upload Remote Session Gateway Certificate ​
POST /userapi/remotesitelocations/gatewaycertificate/
Uploading a new certificate for the Remote Session Gateway of a Remote Site Location can be achieved by making a POST request on the URL, with the SiteID of the Remote Site Location at the end of the URL. The certificate's .pfx file is uploaded in the BODY of the HTTP Post, and its password is specified in the 'CertificatePassword' header. The account executing this call must have the 'Remote Site Locations' Security Administrator's role in Passwordstate.
Passwordstate opens the certificate with its password before saving it, and reads the certificate's expiry date from it. The certificate must contain its private key, must not have expired, and must be no larger than 1 MB. The Agent for the Remote Site Location will then deploy the certificate to the Remote Session Gateway the next time it polls, and restart the Passwordstate-Gateway Windows Service if it is installed.
Note: The certificate's password must be specified in the 'CertificatePassword' header, and not in the QueryString of the URL, so that it is not recorded in the web server's log files.
Powershell
# PowerShell Request
$CertificatePath = "C:\Certificates\Passwordstate.pfx"
$PasswordstateURL = 'https://passwordstate/userapi/remotesitelocations/gatewaycertificate/<SiteID>'
Invoke-Restmethod -Method Post -Uri $PasswordstateURL -InFile $CertificatePath -ContentType "application/x-pkcs12" -Header @{ "UserID" = "<UserID>" ; "APIKey" = "<APIKey>" ; "CertificatePassword" = "<CertificatePassword>" }Json
# Response
HTTP/1.1 200
{
"SiteID":"1",
"SiteLocation":"Contoso",
"GatewayCertificateExpiry":"15/11/2027 11:59:00 PM",
"GatewayCertificateInstallDate":"",
"GatewayCertificateDeployPending":"True",
"GatewayServiceInstallPending":"False"
}