Prajithp / letsencrypt-cpanel

cPanel/WHM plugin for Let's Encrypt client
MIT License
179 stars 61 forks source link

Supports domain without www configured #81

Open rentalhost opened 8 years ago

rentalhost commented 8 years ago

I have some domains that I can't controls the DNS itself. So it's basically registered a subdomain on the master domain to points CNAME/A to main own server. In this case, "subdomain.server.com" is available, but "www.subdomain.server.com" is not. If I try to install on it, it will returns a http-01, because probably it is trying to validate both, www and non-www to Let's Encrypt.

I suggests to check the .well-known access for each returned domain from API. Basically something like (pseudo-code):

if (domain[i].isExternallyAccessible()) {
    allowedDomains.push(domain[i]);
} else {
    unacessibleDomains.push(domain[i]);
}

registerLetsEncrypt(allowedDomains);

if (unacessibleDomains.length > 0) {
    sendMessage('Domains not registered because is inacessible: ' + list(unacessibleDomains))
}
shinji257 commented 8 years ago

Your assumption is correct. I'm trialing cPanel and I just determined that was the cause. Adding cname records on dns for www.sub.domain.com got it to succeed.

The issue is that the plugin is just getting a list of domains + aliases from cPanel.

I did find a more viable workaround (don't want to litter dns) and it does require a little manual editing so I sorta wish cPanel would provide a way to do this in the gui (if it isn't already there... if it is tell me!)

As root on the server go to /var/cpanel/userdata. In there go into the username folder you want to change and edit the file named the domain you want to change and remove the www alias from in there.

For me it showed like this: serveralias: ipv6.sub.domain.com www.sub.domain.com

I just removed the last one. After regenerate your httpd config by running /scripts/rebuildhttpdconf as root

That should take care of it after that. Still kinda a weird way to handle it.

kohenkatz commented 8 years ago

I tried to do what @shinji257 did (removing serveralias from the userdata file), and now I'm getting a different error:

Error occurred: Status: 400, Detail: DNS name was empty, Type: urn:acme:error:malformed