I am currently trying to make a request from my node server to the onasignal REST api. My sites' got https thanks to certbot but on every call I make to their api I got the following error:
{ Error: Hostname/IP doesn't match certificate's altnames: "Host:
localhost. is not in the cert's altnames: DNS:beswapp.io, DNS:www.beswapp.io"
at Object.checkServerIdentity (tls.js:199:17)
at TLSSocket.<anonymous> (_tls_wrap.js:1068:29)
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:185:7)
at TLSSocket._finishInit (_tls_wrap.js:586:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:416:38)
reason: 'Host: localhost. is not in the cert\'s altnames:
DNS:beswapp.io, DNS:www.beswapp.io',
host: 'localhost',
cert:
{ subject: { CN: 'beswapp.io' },
issuer:
{ C: 'US',
O: 'Let\'s Encrypt',
CN: 'Let\'s Encrypt Authority X3' },
subjectaltname: 'DNS:domain.com, DNS:www.domain.com',
infoAccess: { 'OCSP - URI': [Object], 'CA Issuers - URI': [Object] }
I can't figure out how and why my request's hostname is resolved as 'localhost' since I am not running anything on the same machine (client website => my node api => onesignal's api) Here is my code that makes the request:
private get CreateNotificationOptions(): RequestOptions {
return {
host: 'onesignal.com',
hostname: 'domain.com',
port: 443,
path: '/api/v1/notifications',
method: 'POST',
headers: this.Headers,
rejectUnauthorized: false
};
}
sendNotification(data: any): Promise<any> {
console.log('in send notification');
return new Promise<any>((resolve, reject) => {
const req = https.request(this.CreateNotificationOptions, res => {
res.on('data', data => {
resolve(data);
});
});
req.on('error', err => reject(err));
req.write(JSON.stringify(data));
req.end();
});
}
(I recently added the hostname and rejectUnauthorized: false but not any luck) I am using Nginx as a proxy so nginx is doing all the https config job. Any idea ?
via achauchet
No comments:
Post a Comment