node-hue-api
Version:
Philips Hue API Library for Node.js
28 lines (27 loc) • 755 B
JavaScript
import { get } from 'https';
export function getSSLCertificate(url, timeout) {
const options = getRequestOptions(url, timeout);
return performRequest(options);
}
function performRequest(options) {
return new Promise((resolve, reject) => {
get(options, (res) => {
// @ts-ignore
const cert = res.socket.getPeerCertificate();
if (!cert || Object.keys(cert).length < 1) {
reject(`Bridge did not supply a certificate`);
}
else {
resolve(cert);
}
});
});
}
function getRequestOptions(url, timeout) {
return {
hostname: url,
agent: false,
rejectUnauthorized: false,
ciphers: 'ALL'
};
}