Securing back end with Let's Encrypt - multiple aliases [Previously: StartSSL query]

Discussion in 'Installation/Configuration' started by FactionOne, Jun 20, 2017.

  1. FactionOne

    FactionOne Member

    Indeed, I understand the distinction; I'm just wondering what the best way is to deal with the http availability at alpha.serverdomain.tld - with 'nothing' configured for web at that address, the server shows the Debian/Apache default page (not even ISPConfig default); so I'd like to tidy up that too.


  2. sjau

    sjau Local Meanie Moderator

    that's the default apache site if no vhost is found. You probably could setup a website alpha.serverdoman.tld in ISPC as well... or you could redirect it somewhere else...
  3. FactionOne

    FactionOne Member

    OK, thanks - I was just wondering if there's a best practice method.

    Anyway, I've just set-up the site for serverdomain.tld (with auto-www); and with Let's Encrypt enabled for it, I'm back to getting SSL_ERROR_RX_RECORD_TOO_LONG.

    (I don't know if it indicates a problem or not, but I also noticed that with IP address set to *, I only get the Apache default page. I normally specify the IP (just missed it this time), so hadn't noticed it before - once I specify .161, I get the ISPConfig default page as expected.))

    Is there anywhere I can check SSL configuration for a site? Should have been written to serverdomain.tld.vhost, or somewhere else? Is there a relevant log?

    Thanks again,


    [EDIT: I also find that http://alpha.serverdomain.tld now shows the ISPConfig default site, where previously it had shown the Apache one; though I've made no change which should affect that?]
  4. sjau

    sjau Local Meanie Moderator

    you could provide the actual domain name so that we can actually check the cert and stuff
  5. FactionOne

    FactionOne Member

    Hah, I guess. (obfuscating addresses as a matter of course is something I grew up doing, I suppose.)

    From what I can see though, apache isn't offering a certificate for the domain anyway (I've been using the 'add exception' dialogue in Firefox Advanced options [to clarify, I'm not seeing a page with this presented] to request the certificate from the URL).

    Anyway, it's [redacted after tracking issue - #paranoid]

    Last edited: Jun 24, 2017
  6. sjau

    sjau Local Meanie Moderator

    same here... well, right, somethings not right there.... you'll need to check if you have certs in the ssl folder of that domain /var/www/[redacted]/ssl and also have a look at the vhost configuration files for it.... there might have been some issue somewhere.
    Last edited: Jun 24, 2017
    FactionOne likes this.
  7. FactionOne

    FactionOne Member

    heheh - that is what I was wondering :)
    OK. There's nothing in the SSL folder, and there's no :443 vhost or SSL configuration stuff inside the site's .vhost file.
    There's not much of anything (apart from people (bots) browsing the apache manual which is somehow showing in the main domain's access log).
  8. sjau

    sjau Local Meanie Moderator

    not having anything in the ssl folder is not good :)
    FactionOne likes this.
  9. FactionOne

    FactionOne Member

    After all that...

    Where do I submit a bug report? It's working with 3.1.3 :0
    (Exactly the same dependencies etc. - I downloaded both builds and saved an image before installing)

    Thanks for keeping me sane while I worked through it @sjau, I may have one or two queries about your client in a little while (I'll try not to be a pest!) - I'm going to re-read the documentation, and have some coffee & a smoke before I continue...


    PS> I'd be grateful if you could edit your post with the domain name included (I know I'm being paranoid - but it's better safe than sorry, and I don't have the bandwidth for armies of bots!)
  10. sjau

    sjau Local Meanie Moderator

    edited it out.... works great... only thing is if you want to use it for websites created by ispc, you'll just first let ispc create a self-generated cert, so you have config and ssl files in place and then you tell to copy downloaded files at the right location....

    the advantage using ISPC's integrated LE is however, that you can edit stuff on the fly, add new aliases that get included etc....

    with you can just alter the according domain.conf file but you'll have to do changes in two places.

    as for bugs:
    FactionOne likes this.
  11. FactionOne

    FactionOne Member

    Thanks for the edit.

    I think I'll probably let the panel & certbot do their thing for websites, but for everything else I'll use instead of trying to 'fudge' things in the panel. I think I probably get the best of both worlds that way - websites are a bit less reliant upon my memory (having tickboxes and stuff), and non-web services can be secured without getting vhosts all tangled-up.

    Perhaps you might be able to clarify a few points for me before I proceed...

    i) I should leave the API user enabled? (for renewals [or are they 'internally' authenticated, meaning API user only required for initial generation?])
    ii) --reloadcmd is stored, and invoked when certificates are renewed (as well as when they're first installed)?
    iii) For pureftpd, I would concatenate the .key, .crt, and .bundle?
    iv) Does the following look valid? [It relies on my assumptions about (ii) & (iii)]
    Code: --issue --dns dns_ispconfig \
    -d alpha.domain.tld \
    -d ftp.domain.tld \
    -d mail.domain.tld \
    --installcert \
    --certpath /usr/local/ispconfig/interface/ssl/ispserver.crt \
    --keypath /usr/local/ispconfig/interface/ssl/ispserver.key \
    --fullchainpath /usr/local/ispconfig/interface/ssl/ispserver.bundle \
    --reloadcmd "/root/"
    Many thanks again for your help,


    PS> Thanks for bug report link - I'll be sure to file one; hopefully it's useful to the project.
    Last edited: Jun 25, 2017
  12. sjau

    sjau Local Meanie Moderator

    API must be left enabled. So chose a good user with a strong password and grant only the necessary permissions. Everytime you ask for a new cert, you will be asked to answer a challenge ... so everytime it has to alter DNS zone file.

    yes, reloadcmd is run whenever you successfull retrieve new certs. You can alter it anytime by editing the domain.tld.conf file in the ~/ folder... or wherever you told to store the information.

    No idea about pureftpd

    You also wnat to restart/repload apache when you get new certs... if you use the same certs for mail (dovecot/postfix) as well... don't know about the script or what it does... so can't really answer that question.
    FactionOne likes this.
  13. FactionOne

    FactionOne Member

    Thanks for clarifying.

    '' was just my placeholder for a script which would first sort out the certificate for pureftpd, and then restart apache/dovecot/postfix (and pureftpd) as in the ispconfig example you've documented.

    As for pureftpd, I'll figure it out. My query was based upon what I had to do when using a StartSSL certificate, which was to generate a chain from the various CA certificates, then concatenate the key, certificate, and chain into a .pem for pureftpd:

    cat > startssl.chain.class1.server.crt
    cat ispserver.{key,crt} startssl.chain.class1.server.crt > ispserver.pem
    I suppose what I'm actually wondering, is what's inside the .bundle?

    Thanks again!

  14. sjau

    sjau Local Meanie Moderator

    you can also put the same commands into reloadcmd "command1; comannd2; command3". However, after some complexity you may want to use a seperate script like you did...

    Both have advantages or disadvantages.... having it all in the acme config file means it's portable... no need to worry about other scripts....
    Not having it in the conf itself allows you to create much more complex scripts...

    I have this:

    Le_CertCreateTimeStr="Sat Jun  3 22:09:01 UTC 2017" 
    Le_NextRenewTimeStr="Wed Aug  2 22:09:01 UTC 2017" 
    Le_ReloadCmd="systemctl reload apache2; systemctl restart dovecot; systemctl reload postfix" 
    As you can see, the reload command can run seperate commands :)
    FactionOne likes this.
  15. FactionOne

    FactionOne Member

    Magic, thanks. (Also, 'realfullchainpath' suggests that is what I need to append to the key & crt for pureftpd -great.)

  16. sjau

    sjau Local Meanie Moderator

    I just noticed I haven't used dns-01 there :) time to fix that
    ahrasis likes this.
  17. FactionOne

    FactionOne Member

    Hello again :S

    I'm wondering if you can help me out, @sjau ?

    During my troubled attempts last wek with 3.1.4, I hit a letsencrypt rate limit, so I had to wait until today to finalise everything.

    I've got installed, I've tested my regen-pureftp--restart-services script; I've backed-up all my old self-signed certificates, and run the export commands to populate environment variables with my remote API details.

    When I run the command, I just get: Domain is not valid:''
    [where mydomain is my valid domain]

    I've enabled logging in, but there are only two lines above that error (using config, and domain_path)

    The command I executed was:
    ./ --issue --keylength 4096 --dns dns_ispconfig \
    -d \
    -d \
    -d \
    -d \
    -d \
    --installcert \
    --certpath /usr/local/ispconfig/interface/ssl/ispserver.crt \
    --keypath /usr/local/ispconfig/interface/ssl/ispserver.key \
    --fullchainpath /usr/local/ispconfig/interface/ssl/ispserver.bundle \
    --reloadcmd "/root/" has an A record in DNS (I can access it (http) from the machine I'm writing from, which is configured to use Google's DNS servers). The zone is fully configured in ISPConfig.

    I'd be grateful if you could suggest what I've made a mess of! :)



    EDIT: I think the penny may have dropped... Do I need to add the root domain in the command? (Of course it should make any difference that the ISPConfig sites panel has its own certificate for that domain.)

    EDITagain: Oh. That's not it - I just get the error for ' not valid' that way.
    Last edited: Jun 29, 2017
  18. sjau

    sjau Local Meanie Moderator

    is your domain hosted by ISPConfig?
    Did you create a Remote User for ISPConfig?
    Did you export the credentials and URL in the cli before issuing the script?

    The ISPConfig Remote Credentials should be stored in the ~/ file:

    cat account.conf  
    #[email protected]  # the account email used to register account. 
    #USER_AGENT=" (" 
    And why even bother to anonymize your domain? All domains that get a cert through LE are publicated anyway.
    FactionOne likes this.
  19. FactionOne

    FactionOne Member

    As above:

    Yes, the domain is hosted by ISPConfig.
    (The nameservers are glued at the registrar to two of my IPs - one of which is for - which is configured inside a zone in ISPConfig; there's an A record for [actually all the SANs being requested])

    Yes, I set up an ISPC Remote API user with DNS Zone and DNS TXT rights.

    Yes, I exported the details (credentials, URL, and insecure flag) to environment variables; checking with printenv returns them OK.

    All I have in account.conf is:
    ...I installed (with cURL) and ran as root.

    As for anonymizing my domain - I do it because I take a 'better safe than sorry' attitude to security/privacy. Anyone walking down my street can see my house, but there's more snooping required to find out who lives in it; even 0.1% better privacy/security because of that has got to be a good thing? Yes, certificate details are published, but someone searching needs to know what they're looking for. Also, unless I'm a total idiot(?) it doesn't really make a difference i) I'm not one of life's over-confidents, but I'm pretty confident it's set-up correctly; ii) any detail can be posted with 'mydomain' replaced as an example.

    Actually, you'll probably still have my domain in an autocomplete from when you checked that no certificate was being offered with the letsencrypt integration glitch I had [it starts 'g'] :) I'll gladly PM it to you if you wish(?), of course. I don't mean to bite the hand which feeds me - I'm sincerely grateful for (and respectful of) your help; I hope you can understand where I'm coming from.

    Many thanks again,


    EDIT: I noticed that perhaps the syntax I'd suggested above (based on an example in a linked-thread) might not be quite right, according to --help. It appears for output I'd want to be using (for example) --key-file rather than --keypath, that --issue might be extraneous with --installcert(?) (and that probably needed to be --install-cert?)

    Anyway, the latest 'polished' command I've executed is:

    Code: --install-cert --dns dns_ispconfig --keylength 4096 \
    -d \
    -d \
    -d \
    -d \
    -d \
    -d \
    --cert-file /usr/local/ispconfig/interface/ssl/ispserver.crt \
    --key-file /usr/local/ispconfig/interface/ssl/ispserver.key \
    --ca-file /usr/local/ispconfig/interface/ssl/ \
    --reloadcmd "/root/" \
    --fullchain-file /usr/local/ispconfig/interface/ssl/ispserver.bundle
    I've tried with and without --issue, and with and without the first -d entry; every combination returns that the first specified domain is invalid. ...I've even tried dirty things like fudging the API details into the account.conf manually; again with no difference.

    I see only two parts in the main where 'Domain is invalid' might be thrown; in order to double-check that it's happening from within the install-cert function, I edited the error return string. [As one would expect] that is where it's coming from, I'm yet to figure out why :s

    I'll keep looking at the documentation and code myself, but I'm not having much luck.



    EDITagain ..I'll shut up now :|

    I found --debug 2, tried some more. Out of curiosity at some 'no such file or directory' output, I ran mkdir /root/, and it got further, so I chmod -R 777, and this is the output:
    [Fri 30 Jun 00:45:35 UTC 2017] Lets find script dir.
    [Fri 30 Jun 00:45:35 UTC 2017] _SCRIPT_='/root/'
    [Fri 30 Jun 00:45:35 UTC 2017] _script='/root/'
    [Fri 30 Jun 00:45:35 UTC 2017] _script_home='/root/'
    [Fri 30 Jun 00:45:35 UTC 2017] Using config home:/root/
    [Fri 30 Jun 00:45:35 UTC 2017] LE_WORKING_DIR='/root/'
    [Fri 30 Jun 00:45:35 UTC 2017] Using config home:/root/
    [Fri 30 Jun 00:45:35 UTC 2017] _ACME_SERVER_HOST=''
    [Fri 30 Jun 00:45:35 UTC 2017] DOMAIN_PATH='/root/'
    [Fri 30 Jun 00:45:36 UTC 2017] Installing cert to:/usr/local/ispconfig/interface/ssl/ispserver.crt
    cat: /root/ No such file or directory
    [Fri 30 Jun 00:45:36 UTC 2017] Installing CA to:/usr/local/ispconfig/interface/ssl/
    cat: /root/ No such file or directory
    [Fri 30 Jun 00:45:36 UTC 2017] Installing key to:/usr/local/ispconfig/interface/ssl/ispserver.key
    cat: /root/ No such file or directory
    [Fri 30 Jun 00:45:36 UTC 2017] Installing full chain to:/usr/local/ispconfig/interface/ssl/ispserver.bundle
    cat: /root/ No such file or directory
    [Fri 30 Jun 00:45:36 UTC 2017] Run reload cmd: /root/
    regen/restart script test complete
    [Fri 30 Jun 00:45:36 UTC 2017] Reload success
    There are files in the backup folder, and in /usr/local/ispconfig/interface/ssl/, but they're all 0 bytes. There is a file, but it's not got much in it(?) - just paths and reloadcmd. The only recent new certificate shown in the public list [at] is the one issued for the main site by the ISPC LE integration.
    Last edited: Jun 30, 2017
  20. sjau

    sjau Local Meanie Moderator

    seperate --issue and --install into seperate commands. Also provide according log.
    FactionOne likes this.

Share This Page