forked from Fraunhofer-AISEC/cmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
policies.js
32 lines (28 loc) · 903 Bytes
/
policies.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
31
32
// Parse the verification result
var obj = JSON.parse(json);
var success = true;
// Basic checks
if (obj.type != "Verification Result") {
console.log("Invalid type");
success = false;
}
if (!obj.raSuccessful) {
console.log("Attestation not sucessful")
success = false;
}
// Check a certain certificate property in the RTM Manifest
var found = false
for (var i = 0; i < obj.rtmValidation.signatureValidation.length; i++) {
for (var j = 0; j < obj.rtmValidation.signatureValidation[i].validatedCerts.length; j++) {
for (var k = 0; k < obj.rtmValidation.signatureValidation[i].validatedCerts[j].length; k++) {
if (obj.rtmValidation.signatureValidation[i].validatedCerts[j][k].subject.commonName == "CMC Test Leaf Certificate") {
found = true;
}
}
}
}
if (!found) {
console.log("Failed to find certificate 'CMC Test Leaf Certificate'");
success = false;
}
success