@vizamodo/aws-sts-core 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sts/issue.js +27 -17
- package/package.json +1 -1
package/dist/sts/issue.js
CHANGED
|
@@ -255,32 +255,42 @@ function parseCertSerialDec(normalizedCertBase64) {
|
|
|
255
255
|
len = (len << 8) | der[offset++];
|
|
256
256
|
return len;
|
|
257
257
|
}
|
|
258
|
+
// Certificate ::= SEQUENCE
|
|
258
259
|
if (der[offset++] !== 0x30)
|
|
259
260
|
throw new Error("bad cert");
|
|
260
261
|
readLen();
|
|
262
|
+
// tbsCertificate ::= SEQUENCE
|
|
261
263
|
if (der[offset++] !== 0x30)
|
|
262
264
|
throw new Error("bad tbs");
|
|
263
265
|
readLen();
|
|
264
|
-
//
|
|
266
|
+
// Optional version [0] EXPLICIT
|
|
265
267
|
if (der[offset] === 0xa0) {
|
|
266
|
-
offset++;
|
|
267
|
-
offset += readLen();
|
|
268
|
+
offset++; // tag
|
|
269
|
+
offset += readLen(); // skip content
|
|
268
270
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
271
|
+
// Now scan for first INTEGER with "real" length (>2 bytes)
|
|
272
|
+
while (offset < der.length) {
|
|
273
|
+
if (der[offset++] !== 0x02)
|
|
274
|
+
continue;
|
|
275
|
+
const len = readLen();
|
|
276
|
+
if (len <= 2) {
|
|
277
|
+
offset += len; // skip small integers (likely version)
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
if (offset + len > der.length)
|
|
281
|
+
throw new Error("DER overflow");
|
|
282
|
+
let serial = der.slice(offset, offset + len);
|
|
283
|
+
// Strip leading 0x00 ONLY if it's padding
|
|
284
|
+
if (serial.length > 1 && serial[0] === 0x00 && (serial[1] & 0x80) === 0) {
|
|
285
|
+
serial = serial.slice(1);
|
|
286
|
+
}
|
|
287
|
+
let serialBig = 0n;
|
|
288
|
+
for (let i = 0; i < serial.length; i++) {
|
|
289
|
+
serialBig = (serialBig << 8n) | BigInt(serial[i]);
|
|
290
|
+
}
|
|
291
|
+
return serialBig.toString();
|
|
282
292
|
}
|
|
283
|
-
|
|
293
|
+
throw new Error("serial not found");
|
|
284
294
|
}
|
|
285
295
|
catch (e) {
|
|
286
296
|
console.error("[parseCertSerialDec] failed", e);
|