char *path;
char store_path[PATH_MAX]; /* complete path with crt_base */
struct stat st;
+ int fd;
/* if dns-persist-01 is set, add an extra INITIAL_DNS check */
if (strcasecmp(cur_acme->challenge, "dns-persist-01") == 0)
goto out;
}
+ /* the file is created with the process' umask applied, which
+ * commonly leaves it world-readable; this is an unencrypted
+ * private key, restrict it before writing anything into it.
+ */
+ if (BIO_get_fd(bio, &fd) > 0 && fchmod(fd, S_IRUSR | S_IWUSR) == -1) {
+ ha_alert("acme: cannot set the permissions of the file '%s'.\n", cur_acme->account.file);
+ err_code |= ERR_ALERT | ERR_FATAL | ERR_ABORT;
+ goto out;
+ }
+
if ((PEM_write_bio_PrivateKey(bio, key, NULL, NULL, 0, NULL, NULL)) == 0) {
ha_alert("acme: cannot write account key '%s'.\n", cur_acme->account.file);
err_code |= ERR_ALERT | ERR_FATAL | ERR_ABORT;