1
1
import createPrisma from '@/lib/create-prisma'
2
- import { verifyDNSRecord , issueDomainCertificate , checkCertificateStatus , getValidationValues , deleteCertificate } from '@/lib/domain-verification'
2
+ import { verifyDNSRecord , issueDomainCertificate , checkCertificateStatus , getValidationValues , deleteDomainCertificate } from '@/lib/domain-verification'
3
3
import { datePivot } from '@/lib/time'
4
4
5
5
const VERIFICATION_INTERVAL = 60 * 5 // 5 minutes
@@ -81,7 +81,7 @@ async function verifyDomain (domain, models) {
81
81
if ( datePivot ( new Date ( ) , { days : VERIFICATION_HOLD_THRESHOLD } ) > domain . updatedAt ) {
82
82
if ( domain . certificate ) {
83
83
// certificate would expire in 72 hours anyway, it's best to delete it
84
- await deleteCertificate ( domain . certificate . certificateArn )
84
+ await deleteDomainCertificate ( domain . certificate . certificateArn )
85
85
}
86
86
return { status : 'HOLD' , message : `Domain ${ domain . domainName } has been put on HOLD because we couldn't verify it in 48 hours` }
87
87
}
@@ -157,7 +157,7 @@ async function requestCertificate (domain, models) {
157
157
let message = null
158
158
159
159
// ask ACM to request a certificate for the domain
160
- const certificateArn = await issueDomainCertificate ( domain . domainName )
160
+ const { certificateArn, error } = await issueDomainCertificate ( domain . domainName )
161
161
162
162
if ( certificateArn ) {
163
163
// check the status of the just created certificate
@@ -172,7 +172,7 @@ async function requestCertificate (domain, models) {
172
172
} )
173
173
message = 'An ACM certificate with arn ' + certificateArn + ' has been successfully requested'
174
174
} else {
175
- message = 'Could not request an ACM certificate'
175
+ message = 'Could not request an ACM certificate: ' + error
176
176
}
177
177
178
178
const status = certificateArn ? 'PENDING' : 'FAILED'
@@ -184,7 +184,7 @@ async function getACMValidationValues (domain, models, certificateArn) {
184
184
let message = null
185
185
186
186
// get the validation values for the certificate
187
- const validationValues = await getValidationValues ( certificateArn )
187
+ const { validationValues, error } = await getValidationValues ( certificateArn )
188
188
if ( validationValues ) {
189
189
// store the validation values in the database
190
190
await models . domainVerificationRecord . create ( {
@@ -197,7 +197,7 @@ async function getACMValidationValues (domain, models, certificateArn) {
197
197
} )
198
198
message = 'Validation values stored'
199
199
} else {
200
- message = 'Could not get validation values'
200
+ message = 'Could not get validation values: ' + error
201
201
}
202
202
203
203
const status = validationValues ? 'PENDING' : 'FAILED'
@@ -208,7 +208,7 @@ async function getACMValidationValues (domain, models, certificateArn) {
208
208
async function checkACMValidation ( domain , models , record ) {
209
209
let message = null
210
210
211
- const certificateStatus = await checkCertificateStatus ( domain . certificate . certificateArn )
211
+ const { certificateStatus, error } = await checkCertificateStatus ( domain . certificate . certificateArn )
212
212
if ( certificateStatus ) {
213
213
if ( certificateStatus !== domain . certificate . status ) {
214
214
console . log ( `certificate status for ${ domain . domainName } has changed from ${ domain . certificate . status } to ${ certificateStatus } ` )
@@ -219,7 +219,7 @@ async function checkACMValidation (domain, models, record) {
219
219
}
220
220
message = `Certificate status is: ${ certificateStatus } `
221
221
} else {
222
- message = 'Could not check certificate status'
222
+ message = 'Could not check certificate status: ' + error
223
223
}
224
224
225
225
const status = certificateStatus === 'ISSUED' ? 'VERIFIED' : 'PENDING'
0 commit comments