cPanel uapi to deploy a single certificate for multiple domains

glpanel

Member
Jun 24, 2018
10
1
3
Italy
cPanel Access Level
Website Owner
Hello,

I want to use cPanel uapi to deploy a single certificate for multiple domains and subdomains.

If possible I’d like to know If with a single uapi command I can:

1) deploy a single certificate containing a domain and two subdomains (eg. example.com www.example.com cp.example.com or a wildcard *.example.com)

2) deploy a single certificate containing multiple domains (eg. aa.com bb.com cc.com dd.com)

I hope someone can suggest something.

Thank You.
 

cPanelMichael

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

The following UAPI function is available for installing a SSL certificate:

UAPI Functions - SSL::install_ssl - Developer Documentation - cPanel Documentation

You'd need to install it for each domain name individually (using multiple UAPI commands) just as you would via the cPanel UI. Have you considered using the AutoSSL feature instead? It will automatically install free signed SSL certificates for individual domain names and subdomains that are added to the cPanel account.

Thank you.
 

glpanel

Member
Jun 24, 2018
10
1
3
Italy
cPanel Access Level
Website Owner
Hi Michael, thank you for your reply.

"You'd need to install it for each domain name individually" means that to install the certificate of example N°1 I only need a single uapi command, while for example N°2 I must generate four certificates for each domain and install them with four uapi commands ?

As for AutoSSL, I understand that it is a sort of user interface to automate the installation of certificates issued by Let's Encrypt or other certificate authority, in this case my hosting provider has not enabled this cPanel module.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
"You'd need to install it for each domain name individually" means that to install the certificate of example N°1 I only need a single uapi command, while for example N°2 I must generate four certificates for each domain and install them with four uapi commands ?
Hello @glpanel,

It depends on the type of certificate you are installing. For instance, is it a standard SSL certificate that covers a single domain name, a wildcard SSL certificate, or a multi-domain (UCC) certificate?

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
I want to install a standard certificate that covers a domain and subdomain like example.com www.example.com
In that case, yes, a single UAPI command is all you'd need. EX:

Code:
uapi SSL install_ssl domain=example.com cert=THECERTIFICATETEXT key=THEKEYTEXT cabundle=THECABUNDLETEXT
You wouldn't need to run an additional command for the "www" subdomain, as it's included by default as part of the installation.

Thank you.
 

cPanelFelipe

Member
Staff member
Apr 10, 2013
21
15
128
Quick clarification: install_ssl does NOT install certificates onto “domains” per se; rather, it first installs them onto Apache httpd virtual hosts and then creates appropriate entries for non-httpd SSL services (e.g., Dovecot, Exim, cpsrvd, …).

Consider a case where “example.com” and “haha.org” share an Apache virtual host. While install_ssl will accept either of those domain names, it’s not possible to have separate SSL certificates for the two domains; an installation for one will overwrite the installation for the other. Thus, the only way to secure both domains is to have a certificate that matches both domains.

This is all because Apache httpd associates SSL certificates with virtual hosts, not with domain names. It’s an unfortunate design that creates a lot of confusion.
 
  • Like
Reactions: cPanelMichael