mirror of
https://github.com/Koenkk/zigbee-OTA.git
synced 2026-09-21 03:58:44 +00:00
feat: support for custom CA certificates (#422)
- Adds custom CA certificate for Philips Hue OTA updates - Adds support to use these certificates to `scripts/add.js` - Adds concatenation of CA certs to `scripts/updateall.js` Part of the fixes for https://github.com/Koenkk/zigbee-OTA/issues/420 Signed-off-by: Felix Kaechele <felix@kaechele.ca>
This commit is contained in:
+7
-1
@@ -1,10 +1,12 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const crypto = require('crypto');
|
||||
const tls = require('tls');
|
||||
const ota = require('../lib/ota');
|
||||
const filenameOrURL = process.argv[2];
|
||||
const modelId = process.argv[3];
|
||||
const baseURL = 'https://github.com/Koenkk/zigbee-OTA/raw/master';
|
||||
const caCerts = './cacerts.pem';
|
||||
|
||||
const manufacturerNameLookup = {
|
||||
123: 'UHome',
|
||||
@@ -53,7 +55,11 @@ const main = async () => {
|
||||
const file = fs.createWriteStream(path);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = lib.get(url, function(response) {
|
||||
const ca = [...tls.rootCertificates];
|
||||
if(fs.existsSync(caCerts)) {
|
||||
ca.push(fs.readFileSync(caCerts));
|
||||
}
|
||||
const request = lib.get(url, { ca }, function(response) {
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
response.pipe(file);
|
||||
file.on('finish', function() {
|
||||
|
||||
Reference in New Issue
Block a user