How to change the ArcGIS Server web server certificate using ArcGIS API for Python

12-09-2022 04:37 AM
Labels (2)
New Contributor II


I'm trying to update the web server SSL certificate for ArcGIS Server using ArcGIS API for Python.

I was able to do that for Portal for ArcGIS as shown below:portalcert.PNG

I was also able to import the certificate to ArcGIS Server as shown below:


However, I can't find any documentation about updating the Web Server SSL certificate for ArcGIS Server.

Please note that I tried the following:

I seem to have been able to update the Web server certificate, however, it doesn't seem to persist for some reason:


The result of the first loop is the changed certificate:


However, when the loop finishes, it seems to be reverted back to the previous certificate, as this is the result of the second loop:


Please note that I restarted the ArcGIS Server service.

Any help would be appreciated!

Tags (2)
0 Kudos
1 Reply
New Contributor II

Hello @DanaNajeeb ,

Did you manage changing the server certificate alias via API for Python? 
I successfully automated it using a curl command inside a Python script:

curl_command = 'C:\Windows\System32\curl.exe -s -X POST "https://'+server+':6443/arcgis/admin/machines/'+server.upper()+'/edit" -H "Host: '+server.upper()+'" -H "Content-Type: application/x-www-form-urlencoded" --data-urlencode "adminURL=https://'+server.upper()+':6443/arcgis/admin" --data-urlencode "machineName='+server.upper()+'" --data-urlencode "webServerMaxHeapSize=-1" --data-urlencode "webServerCertificateAlias=certificate" --data-urlencode "socMaxHeapSize=64" --data-urlencode "underMaintenance=false" --data-urlencode "f=json" --data-urlencode token='+'"'+str(token)+'"'


0 Kudos