Question

Is it possible to setup SSL protected subdomains using the DigitalOcean API?

I am building an application that allows users to build out-static websites on a subdomain within my application. I am curious what the most scaleable way to go about this is.

Currently, I plan on using the DigitalOcean API’s domain endpoints to create new CNAME and A records for the user. but I am not sure how to also provide SSL solely through the API.

Techstack: Next.js, Vercel, Node, DigitalOcean, NGINX, MongoDB


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi there @alexdc2,

I don’t think that this could be achieved via the API. The DigitalOcean managed SSL certificates, are primarily used for managed services like load balancers and Spaces.

In your case, you could have a different automation system on your server itself that triggers a Let’s Encrypt validation process once your DNS records are in place.

You could use the certbot command-line tool to do that. And you could build this into your application creation process right after the DNS creation step.

You could follow the steps on how to use certbot here:

https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-20-04

Alternatively, you could issue a single wildcard SSL certificate for your main domain name and it would cover all of the possible subdomains (eg *.yourdomain.com), that way you would not have to issue separate SSL certificates for each subdomain. You could follow the steps here on how to set that up:

https://www.digitalocean.com/community/tutorials/how-to-create-let-s-encrypt-wildcard-certificates-with-certbot

Hope that this helps!

Regards, Bobby