Hello. I want to send data to my server using my certificate, but an error occurs.
self signed certificate in certificate chain at TLSSocket.onConnectSecure (_tls_wrap.js:1473:34)
Cloud Code
const https = require('https');
const globalOptions = {
hostname: 'HERE MY HOSTNAME',
port: 4433,
path: '/',
method: 'POST',
ca: '-----BEGIN CERTIFICATE----- HERE MY CERTIFICATE -----END CERTIFICATE-----'
};
module.exports = async function (event) {
var eventString = JSON.stringify(event);
var options = globalOptions;
options.headers = {
'Content-Type': 'application/json',
'Content-Length': eventString.length
};
await doRequest(options, eventString);
}
function doRequest(options, data) {
return new Promise((resolve, reject) => {
const req = https.request(options, (res) => {
res.setEncoding('utf8');
let responseBody = '';
res.on('data', (chunk) => {
responseBody += chunk;
});
res.on('end', () => {
resolve(JSON.parse(responseBody));
});
});
req.on('error', (err) => {
reject(err);
});
req.write(data)
req.end();
});
}