apacheubuntuhttpsssl-certificatewildcard-subdomain

Wildcard SSL certificates for multiple subdomain


I have a system with multiple clients. Each client has their own subdomain.

client1.example.com
client2.example.com
...

At the server side, all requests are redirected to *.example.com. Then my business logic reads the subdomain (like client1) and gives response to the client accordingly.

So basically, I do not configure each subdomain on the server. I just add it to my database and my code handles it properly.

I am trying to apply wildcard SSL certificates to all these subdomains. Also, I want all future clients to automatically get https.

But I don't know how to configure this. I have tried using Let's Encrypt, but no luck. The actual domain example.com gets https but not the client domains.

Any help with configuration would be really helpful. Or, may be, this setup is just not possible. I don't know.

Please help.

P.S. example.com is just a dummy domain I am referring to.

P.P.S. I use apache2 web server on Ubuntu 16.04 x64


Solution

  • Well, it is possible. I now have a certificate in place for *.example.com and it works on all my arbitrary subdomains, viz.,

    client1.example.com
    client2.example.com
    ...
    

    I followed these steps:

    $ wget https://dl.eff.org/certbot-auto
    $ chmod a+x ./certbot-auto
    
    $ sudo ./certbot-auto certonly \
    --server https://acme-v02.api.letsencrypt.org/directory \
    --manual --preferred-challenges dns \
    -d *.example.com
    

    Then using the files created at /etc/letsencrypt/live/example.com/, I updated the values from my control panel (I use Vestacp)

    cat /etc/letsencrypt/live/example.com/cert.pem
    ^ Copy contents into “SSL Certificate” field.
    
    cat /etc/letsencrypt/live/example.com/privkey.pem
    ^ Copy contents into “SSL Key” field.
    
    cat /etc/letsencrypt/live/example.com/chain.pem
    ^ Copy contents into “SSL CA / Intermediate” field.
    

    Make changes according to your control panel.

    Follow this article for detailed steps and explanation.