1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

chasquid: De-couple TLS certificates from domains

Having the certificates inside the domain directory may cause some confusion,
as it's possible they're not for the same name (they should be for the MX we
serve as, not the domain itself).

So it's not a problem if we have domains with no certificates (we could be
their MX with another name), and we could have more than one certificate per
"domain" (if we act as MXs with different names).

So this patch moves the certificates out of the domains into a new certs/
directory, where we do a one-level deep lookup for the files.

While at it, change the names of the files to "fullchain.pem" and
"privkey.pem", which match the names generated by the letsencrypt client, to
make it easier to set up.  There's no general convention for these names
anyway.
This commit is contained in:
Alberto Bertogli
2016-10-01 13:54:09 +01:00
parent 04dd8b9534
commit e138f0dc05
7 changed files with 58 additions and 52 deletions

View File

@@ -142,16 +142,16 @@ func main() {
log.Fatalf("Failed to create certificate: %s", err)
}
certOut, err := os.Create("cert.pem")
certOut, err := os.Create("fullchain.pem")
if err != nil {
log.Fatalf("failed to open cert.pem for writing: %s", err)
log.Fatalf("failed to open fullchain.pem for writing: %s", err)
}
pem.Encode(certOut, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes})
certOut.Close()
keyOut, err := os.OpenFile("key.pem", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
keyOut, err := os.OpenFile("privkey.pem", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
log.Fatalf("failed to open key.pem for writing:", err)
log.Fatalf("failed to open privkey.pem for writing:", err)
return
}
pem.Encode(keyOut, pemBlockForKey(priv))

View File

@@ -80,11 +80,11 @@ function wait_for_file() {
done
}
# Generate certs for the given domain.
# Generate certs for the given hostname.
function generate_certs_for() {
mkdir -p config/domains/${1}
mkdir -p config/certs/${1}/
(
cd config/domains/${1}
cd config/certs/${1}
generate_cert -ca -duration=1h -host=${1}
)
}