• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Issue Issue SSL cert via REST API

BenC

New Pleskian
Server operating system version
Windows
Plesk version and microupdate number
Version 18.0.55 Update #2
Hi,
I have been trying the REST API for creating/renewing certificates. I saw the useful article here https://support.plesk.com/hc/en-us/articles/12377059948183 I cant get the code to work, however i am making some assumptions that the files are meant to be on the computer making the curl request.

Bash:
curl -k -X POST -H "X-API-Key: ce8b9a38-4410-. . ." -H "Content-Type: application/json" -H "Accept: application/json" "https://<Server_IP>:8443/api/v2/cli/certificate/call" -d '{ "params": ["--create", "mynewcert", "-domain", "example.com", "-csr-file", "server.csr", "-key-file", "server.key"]}'

When I try the above (with the correct API key) I get the error

Bash:
"code": 1,
    "stdout": "",
    "stderr": "Unable to create certificate \"mynewcert\": file server.csr dose not exist"

The files are in the directory I am running the curl command from (linux machine). I have tried specifying the file as
Code:
server.csr
,
Code:
./server.csr
and
Code:
@server.csr

Are the files meant to be on the computer you are making the curl request from ? or are they meant to be on the server ?
If they are meant to be on the (windows) server , do you state the full file path e.g D:\certs\server.csr ? (I did try this as well , but got the same error.)
I have a feeling i am missing something obvious here.

Any help appreciated.

Kind Regards,
Ben
 
The files are meant to be on the same server you are running the command/api call on. The full path should be used for both the key and the csr file. Like for example D:\certs\server.csr.

For this particular API call, the call gets forwarded the CLI. To trouble shoot your issue you could try and see if are able to create/issue a certificate via CLI directly. See Plesk CLI documentation for Windows here.
 
Back
Top