# cPanel API 2 Functions - SSL::getcnname Warning: The cPanel API 2 system is deprecated. We **strongly** recommend that you use [UAPI](/cpanel/introduction) instead of cPanel API 2. ## Description This function lists SSL certificate information for a cPanel service. Warning: We **strongly** recommend that you use the following [UAPI](/cpanel/introduction/) function instead of this function: - [`SSL::get_cn_name`](https://api.docs.cpanel.net/openapi/cpanel/operation/get_cn_name/) — This function retrieves the most secure domain for a service. ## Examples ### WHM API (JSON) ```undefined syntaxhighlighter-pre https://hostname.example.com:2087/cpsess###########/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=SSL&cpanel_jsonapi_func=getcnname&domain="example.com"&service="imap"&add_mail_subdomain="0" ``` Note: For more information, read our [Calls from the WHM API](/whm/use-whm-api-to-call-cpanel-api-and-uapi) documentation. ### LiveAPI PHP Class ```undefined syntaxhighlighter-pre $cpanel = new CPANEL(); // Connect to cPanel - only do this once. // Get certificate information for example.com's IMAP server. $get_certificate_info = $cpanel->api2( 'SSL', 'getcnname', array( 'domain' => 'example.com', 'service' => 'imap', 'add_mail_subdomain' => '0', ) ); ``` Note: For more information, read our [Guide to the LiveAPI System](/guides/guide-to-the-liveapi-system/#guide-to-the-liveapi-system). ### LiveAPI Perl Module ```undefined syntaxhighlighter-pre my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once. # Get certificate information for example.com's IMAP server. my $get_certificate_info = $cpliveapi->api2( 'SSL', 'getcnname', { 'domain' => 'example.com', 'service' => 'imap', 'add_mail_subdomain' => '0', } ); ``` Note: For more information, read our [Guide to the LiveAPI System](/guides/guide-to-the-liveapi-system). ### cPanel Tag System (deprecated) Warnings: - cPanel tags are **deprecated**. We **strongly** recommend that you **only** use the [LiveAPI](/guides/guide-to-the-liveapi-system) system to call the cPanel APIs. Examples are **only** present in order to help developers move from the old cPanel tag system to our [LiveAPI](/guides/guide-to-the-liveapi-system). - cPanel API 2 calls that use cPanel tags vary in code syntax and in their output. - For more information, read our [Deprecated cPanel Tag Usage](/cpanel-api-2/cpanel-api-2-deprecate-cpanel-tag-usage/) documentation. ### Command Line ```undefined syntaxhighlighter-pre cpapi2 --user=username SSL getcnname domain=example.com service=imap add_mail_subdomain=0 ``` div Notes: - You **must** URI-encode values. - `username` represents your account-level username. - You **must** include the `--user=username` option. - For more information and additional output options, read our [Guide to cPanel API 2](/cpanel-api-2/) documentation or run the `cpapi2 --help` command. - If you run CloudLinux™, you **must** use the full path of the `cpapi2` command: ```undefined syntaxhighlighter-pre /usr/local/cpanel/bin/cpapi2 ``` ### Output (JSON) ```undefined syntaxhighlighter-pre { "cpanelresult": { "apiversion": 2, "func": "getcnname", "data": [ { "is_self_signed": 1, "ssldomain": "example.com", "is_wild_card": 0, "ssldomain_matches_cert": 1, "cert_match_method": "hostname", "cert_valid_not_after": "1436471749" } ], "event": { "result": 1 }, "module": "SSL" } } ``` Note: Use cPanel's *[API Shell](https://docs.cpanel.net/cpanel/advanced/api-shell-for-cpanel)* interface (*cPanel >> Home >> Advanced >> API Shell*) to directly test cPanel API calls. ## Parameters table colgroup col col col col col thead tr th strong Parameter th strong Type th strong Description th strong Possible values th strong Example tbody tr td code domain td em string td p strong Required p The domain name. td p An SSL-enabled domain on the cPanel account. td code example.com tr td code service td em string td p strong Required p The service for which to retrieve information. td ul li code imap — Return IMAP server information. li code pop3 — Return POP3 server information. li code smtp — Return SMTP (Exim) server information. li code dav — Return em Web Disk information. li code cpanel — Return cPanel & WHM information. p If you specify code imap or code pop3 , the mail server strong must be configured, and strong cannot be disabled. td code imap tr td code add_mail_subdomain td em Boolean td p Whether to append code mail or code www onto the code domain value in order to find a match. p For example, if you specify the domain code example.com and enable this option, the function searches for service information from code mail.example.com , code www.example.com , and code example.com . p This parameter defaults to code 0 . td ul li code 1 — Append code mail and code www onto the code domain value during search. li code 0 — Match on the specified code domain value only. td code 0 ## Returns table colgroup col col col col col thead tr th strong Return th strong Type th strong Description th strong Possible values th strong Example tbody tr td code is_self_signed td em Boolean td Whether the certificate is a self-signed certificate. td ul li code 1 — Self-signed certificate. li code 0 — Third-party certificate. td code 1 tr td code ssldomain td em string td The domain for which the certificate was issued. td A valid domain name. td code example.com tr td code is_wild_card td em Boolean td Whether the certificate is a wildcard certificate. td ul li code 1 — The certificate is a wildcard certificate. li code 0 — The certificate is not a wildcard certificate. td code 0 tr td code ssldomain_matches_cert td em Boolean td Whether the certificate information matches the domain. td ul li code 1 — The certificate and domain match. li code 0 — The certificate and domain do not match. td code 1 tr td code cert_match_method td em string td The type of match. td ul li code hostname — The certificate hostname and the domain hostname match. li code exact — All certificate and domain details match. li code exact-wildcard — All certificate and domain details match for a wildcard certificate. li code www-wildcard — The certificate matches the domain value when the system appends code www . li code mail-wildcard — The certificate matches the domain value when the system appends code mail . li code localdomain_on_cert — The certificate matches another domain on the server. li code localdomain_on_cert-www-wildcard — The certificate matches another domain on the server when the system appends code www . li code localdomain_on_cert-mail-wildcard — The certificate matches another domain on the server when the system appends code mail . td code hostname tr td code cert_valid_not_after td em integer td The certificate's expiration date. td The certificate's expiration date, in a Unix time . td code 1436471749 tr td code reason td em string td p A reason for failure. This function only returns a code reason value if there was an error. td A string that describes the error. td code This is an error message. tr td code result td em Boolean td p Whether the function succeeded. td ul li code 1 — The function succeeded. li code 0 — The function failed. td code 1