return location certificates
This commit is contained in:
@@ -276,17 +276,17 @@ function getAcmeCertificatePathSync(fqdn, domainObject) {
|
||||
return { certName, certFilePath, keyFilePath, csrFilePath, acmeChallengesDir };
|
||||
}
|
||||
|
||||
async function setAppCertificate(subdomain, domainObject, bundle) {
|
||||
async function setAppCertificate(subdomain, domainObject, certificate) {
|
||||
assert.strictEqual(typeof subdomain, 'string');
|
||||
assert.strictEqual(typeof domainObject, 'object');
|
||||
assert(bundle && typeof bundle === 'object');
|
||||
assert.strictEqual(typeof certificate, 'object');
|
||||
|
||||
const fqdn = dns.fqdn(subdomain, domainObject);
|
||||
const { certFilePath, keyFilePath } = getAppCertificatePathSync(fqdn);
|
||||
|
||||
if (bundle.cert && bundle.key) {
|
||||
if (!safe.fs.writeFileSync(certFilePath, bundle.cert)) throw safe.error;
|
||||
if (!safe.fs.writeFileSync(keyFilePath, bundle.key)) throw safe.error;
|
||||
if (certificate !== null) {
|
||||
if (!safe.fs.writeFileSync(certFilePath, certificate.cert)) throw safe.error;
|
||||
if (!safe.fs.writeFileSync(keyFilePath, certificate.key)) throw safe.error;
|
||||
} else { // remove existing cert/key
|
||||
if (!safe.fs.unlinkSync(certFilePath)) debug(`Error removing cert: ${safe.error.message}`);
|
||||
if (!safe.fs.unlinkSync(keyFilePath)) debug(`Error removing key: ${safe.error.message}`);
|
||||
|
||||
Reference in New Issue
Block a user