The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'cPanel Developers' started by swbrains, Oct 3, 2016.

Tags:
  1. swbrains

    swbrains Active Member

    Joined:
    Sep 13, 2006
    Messages:
    40
    Likes Received:
    2
    Trophy Points:
    8
    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
     
    #1 swbrains, Oct 3, 2016
    Last edited: Oct 3, 2016
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  3. swbrains

    swbrains Active Member

    Joined:
    Sep 13, 2006
    Messages:
    40
    Likes Received:
    2
    Trophy Points:
    8
    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!
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  5. swbrains

    swbrains Active Member

    Joined:
    Sep 13, 2006
    Messages:
    40
    Likes Received:
    2
    Trophy Points:
    8
    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?
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
Loading...

Share This Page