ImportExistingServerCertificate error Unable to find root ca certificate

214
3
02-26-2024 08:28 AM
Labels (1)
np_al
by
New Contributor II

I am trying to use 'importExistingServerCertificate'  using powershell and REST API and I get the error 'Unable to find root ca certificate.

$rootUri =  'https://<server.domain.com>:6443/arcgis/admin/machines/<machine name>/sslcertificates/importExistingServerCertificate'

$params = @{
alias = 'mapcert';
certPassword = '<password>';
certFile = 'c:\certificates\<certname>.pfx';
f = 'json'
}

Invoke-RestMethod -Uri $rootUri -Method Post -Body $params

I can manually install the certificate from the arcgis/admin/machines/<> page no issues, but when trying to automate it is when it throws the error. @JoshuaBixby Hoping you might be able to help 😁 

Thanks,
Noel

 

0 Kudos
3 Replies
JoshuaBixby
MVP Esteemed Contributor

With the Esri Admin API call, you need to include the file in the POST body.  Your current code is including a path to a file and not the contents of the file.

0 Kudos
np_al
by
New Contributor II

@JoshuaBixby forgive my ignorance but would just adding a get-content ie $cert = get-content c:\certificate\certificate.pfx then making the parameter for certFile = $cert resolve this?

Maybe I am over simplifying but I was under the impression the rest api call would read the certificate like it does in the admin page.

 

 

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

In the Admin API page, there is a "Choose File" button.  That button isn't about giving ArcGIS Server the path to the file on your machine, which it can't do anything with anyways, that button is actually uploading the contents of the file in the browser session so that when you hit Submit the file contents can be sent.

0 Kudos