go-acme / lego

Let's Encrypt/ACME client and library written in Go
https://go-acme.github.io/lego/
MIT License
8.07k stars 1.03k forks source link

fullchain.pem #298

Closed JoyceBabu closed 8 years ago

JoyceBabu commented 8 years ago

How can I generate fullchain.pem? Why isn't it generated with the other files?

xenolf commented 8 years ago

Hello there! The file we generate only has the intermediate and the client certificate in it which should generally be enough. What is your usecase where you need the CA cert as well?

JoyceBabu commented 8 years ago

I did not realize that the .crt file contained the Lets Encrypt CA certificate too. Sorry.

im7mortal commented 7 years ago

To generate fullchain.pem

certificates, failures := client.ObtainCertificate([]string{"example.com"}, b, nil, false)
// ...
fullchain := []byte{}
fullchain = append(fullchain, certificates.Certificate...)
fullchain = append(fullchain, certificates.IssuerCertificate...)

Then

ioutil.WriteFile("cert.pem", certificates.Certificate, 0644)
ioutil.WriteFile("chain.pem", certificates.IssuerCertificate, 0644)
ioutil.WriteFile("fullchain.pem", fullchain, 0644)
ioutil.WriteFile("privkey.pem", certificates.PrivateKey, 0640)
Poikilos commented 2 months ago

Uh, where does that code go?

Use cases:

SOLVED for ZNC

ZNC_CERTS_DIR=/home/znc/.znc/certs
mkdir -p $ZNC_CERTS_DIR || exit $?
cp -p /var/letse/$LETSE_USER/certificates/example.com.* $ZNC_CERTS_DIR/ || exit $?
cd $ZNC_CERTS_DIR || exit $?
cat *.key *.crt                >  znc.pem
cat /etc/ssl/certs/dhparam.pem >> znc.pem
chown znc:znc -R $ZNC_CERTS_DIR || exit 1 
# restart znc here (set service to run as znc user)

Examples not using lego:

Related issues:

SOLVED for weechat

Used different order for weechat recommended by Glowing Bear's Getting Started, constructing fullchain.pem same way as "where does that code go" above:

RELAY_DOM=example.com
RELAY_CERTS_DIR=/home/weechat/.weechat/certs
# ^ weechat's default location for relay.pem
mkdir -p $RELAY_CERTS_DIR || exit $?
cp -p /var/letse/$LETSE_USER/certificates/example.com.* $RELAY_CERTS_DIR/ || exit $?
cd $RELAY_CERTS_DIR || exit $?

cat $RELAY_DOM.crt $RELAY_DOM.issuer.crt > fullchain.pem
cat fullchain.pem $RELAY_DOM.key > relay.pem
# ^ key last as per Glowing Bear "Getting Started" guide

chown weechat:weechat -R $RELAY_CERTS_DIR || exit 1 
# restart weechat here (set service to run as weechat user)

Remaining concerns: