UAPI Functions SSL::list_certs -- finding single installed certificate

swbrains

Well-Known Member
Sep 13, 2006
306
45
178
I have an account that I have been testing with LetsEncrypt. I've generated several "real" SSL certs for this account, and also some "test" certificates via LetsEncrypt. in each case, I deleted the currently installed cert via cPanel, then ran my script to get a new certificate and install it. I only ever have one certificate installed on the account according to cPanel's SSL page where it lists the SSL certificates installed on the account. If I use cPanel to delete that one certificate listed on the SSL management page, the site is no longer available as an https: site, so I know that is the only certificate cPanel recognizes as active on this account.

After a number of tests installing and deleting certificates (again only one is currently showing as installed in cPanel), I decided to write a function to display the currently installed certificate's information. I couldn't find an API function to get just the one installed certificate according to cPanel, so I used list_certs, specifying this account's domain. It successfully returns, but it contains elements for all the certificates I ever installed on this account, even though they're not listed in cPanel for this account (only one is shown). Although this seemed odd, I figured I would loop over them and only one would have the "domain_is_configured" value set to "1", as cPanel only shows one certificate installed on the account, but they ALL come back with "1" for this value.

Is there an API method to do what cPanel is doing? That is, retrieve the information for the *one* SSL certificate that is shown as actively installed on the account?

Thanks,
Vinnie
 
Last edited:

swbrains

Well-Known Member
Sep 13, 2006
306
45
178
Thanks! I just tried calling install_host and got the response below. I'm not sure what I'm doing wrong (I do know it's authenticating properly with the account's user ID and password)...

The URL that I called from my script:
https://subdomain.mydomain.com:2083/execute/SSL/installed_host?domain=subdomain.mydomain.com

The JSON response from the call (the IP was correct for this account):
{"status":0,"errors":["Unable to retrieve the certificate installed on IP address XX.XX.XX.XX: "],"data":null,"messages":null,"metadata":{}}

The site running the script that outputs this information after calling the function has a valid SSL cert installed per the browser developer panel (see screenshot attached):
screencapture_000277.png

Thanks again!
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463

swbrains

Well-Known Member
Sep 13, 2006
306
45
178
Ah yes! Thanks! I just tried install_hosts and that does return valid certificate information. Is that function designed to return just the *one* installed certificate for this account like cPanel shows and ignore other certificates that may have also been installed at one time?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Is that function designed to return just the *one* installed certificate for this account like cPanel shows and ignore other certificates that may have also been installed at one time?
Hello,

Yes, it's designed to show the certificates that are installed under that cPanel account, as opposed to providing a list of all CRT files generated/existing for that account.

Thank you.