WHM API 1 - install_service_ssl_certificate - cabundle confusion

gwurr3

Registered
Jun 7, 2014
4
0
1
cPanel Access Level
Root Administrator
Hi guys,

I've got a script working that installs service SSL certs.
It works fine if the server already has the correct cabundle.

However, if, say, I'm on a fresh server load without the cabundle, it will fail.

I've tried specifying the ca-bundle as:
plaintext ( with or without newlines )
uri-encoded text ( with or without newlines )
a filepath to a file on the server containing the cabundle
etc

I can't seem to figure this out.
https://documentation.cpanel.net/display/SDK/WHM+API+1+Functions+-+install_service_ssl_certificate says to use:
A valid .crtfile on the server. example "ca-bundle.crt"

I'm guessing it just wants to take in an argument like "ca-bundle.crt" instead of a full filepath.
If this is the case, what directory is it searching in?

I'm doing this from a perl script via a http request:
localhost:2087/json-api/install_service_ssl_certificate?api.version=1&service=cpanel&crt=$cert&key=$key
I've also tried the xml api with the same results

Thanks in advance for your time.
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,254
463
Hello :)

You should pass the contents of the CRT for "cabundle" the same way you do for "crt" and "key". Do you receive a specific failure message?

Thank you.
 

gwurr3

Registered
Jun 7, 2014
4
0
1
cPanel Access Level
Root Administrator
This is what I get:

{"metadata":{"version":1,"reason":"Certificate verification failed!\nThe system did not find the Certificate Authority Bundle that matches this certificate.\nContact “GlobalSign nv-sa” to obtain the Certificate Authority Bundle for “AlphaSSL CA - SHA256 - G2”.","result":0,"command":"install_service_ssl_certificate"}}

This only occurs if the server is a fresh load and has never had an SSL installed via WHM, yet.
It seems once we login to WHM and setup the cert with the "autofill by certificate" option, it corrects the issue.
After adding the cert via WHM, I can then remove it completely and then the API call will now work.
I'm guessing that the CA Bundle is getting cached somewhere or something after using the autofill option.

btw this is using: json-api/install_service_ssl_certificate?api.version=1&service=cpanel&crt=$cert&key=$key&cabundle=$cab

Sorry for the late reply, and thanks :)
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,254
463
Could you open a support ticket using the link in my signature so we can take a closer look? You can post the ticket number here so we can update this thread with the outcome.

Thank you.