UNPKG

node-hue-api

Version:
32 lines (31 loc) 926 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getSSLCertificate = void 0; const https_1 = require("https"); function getSSLCertificate(url, timeout) { const options = getRequestOptions(url, timeout); return performRequest(options); } exports.getSSLCertificate = getSSLCertificate; function performRequest(options) { return new Promise((resolve, reject) => { (0, https_1.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' }; }