-
Notifications
You must be signed in to change notification settings - Fork 0
/
GG_CA.js
30 lines (26 loc) · 904 Bytes
/
GG_CA.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var https = require('https');
var fs = require("fs");
var options = {
host: 'a33jti3e3cvwks-ats.iot.us-east-1.amazonaws.com',
port: 8443,
path: '/greengrass/discover/thing/Capstone_Jetson',
method: 'GET',
key: fs.readFileSync("certs/private.pem.key"),
cert: fs.readFileSync("certs/certificate.pem.crt"),
ca: fs.readFileSync("certs/AmazonRootCA1.pem")
};
var req = https.request(options, function(res) {
res.on('data', function(d) {
var jsonObject = JSON.parse(d);
console.log(JSON.stringify(jsonObject))
console.log(jsonObject.GGGroups[0].CAs)
fs.writeFile("certs/gg-CA.crt", jsonObject.GGGroups[0].CAs[0], (err) => {
if (err) throw err;
console.log('The file has been saved!');
});
});
});
req.end();
req.on('error',function(e) {
console.error(e);
});