Upload Remote Session Gateway Certificate ​
POST /userapi/gatewaydeployments/gatewaycertificate/
Uploading a new certificate for the Remote Session Gateway of a Gateway Deployment can be achieved by making a POST request on the URL, with the HostName of the Gateway Deployment 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 'PS Remote Sessions' 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. For an Embedded gateway, the Passwordstate Windows Service on the web server installs the certificate within about a minute. For an External gateway, the Passwordstate Gateway Maintenance Windows Service on the gateway host installs the certificate within about five minutes. Either restarts 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/gatewaydeployments/gatewaycertificate/<HostName>'
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
{
"HostName":"GW01",
"InstallType":"External",
"GatewayCertificateExpiry":"15/11/2027 11:59:00 PM",
"GatewayCertificateInstallDate":"",
"GatewayCertificateDeployPending":"True",
"GatewayServiceInstallPending":"False"
}