1
1
import { requestCertificate , getCertificateStatus , describeCertificate } from '@/api/acm'
2
- import { promises as dnsPromises } from 'node:dns'
2
+ import { Resolver } from 'node:dns/promises '
3
3
4
4
// Issue a certificate for a custom domain
5
5
export async function issueDomainCertificate ( domainName ) {
@@ -69,11 +69,12 @@ export async function verifyDomainDNS (domainName, verificationTxt, verification
69
69
}
70
70
71
71
// by default use cloudflare DNS resolver
72
- dnsPromises . setServers ( [ process . env . DNS_RESOLVER || '1.1.1.1' ] )
72
+ const resolver = new Resolver ( )
73
+ resolver . setServers ( [ process . env . DNS_RESOLVER || '1.1.1.1' ] )
73
74
74
75
// TXT Records checking
75
76
try {
76
- const txtRecords = await dnsPromises . resolve ( txtHost , 'TXT' )
77
+ const txtRecords = await resolver . resolveTxt ( txtHost )
77
78
const txtText = txtRecords . flat ( ) . join ( ' ' )
78
79
79
80
// the TXT record should include the verificationTxt that we have in the database
@@ -88,7 +89,7 @@ export async function verifyDomainDNS (domainName, verificationTxt, verification
88
89
89
90
// CNAME Records checking
90
91
try {
91
- const cnameRecords = await dnsPromises . resolve ( domainName , 'CNAME' )
92
+ const cnameRecords = await resolver . resolveCname ( domainName )
92
93
93
94
// the CNAME record should include the cname that we have in the database
94
95
result . cnameValid = cnameRecords . some ( record =>
0 commit comments