MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / getKey

Method getKey

modules/crypt/ssl/ssl_cert.js:68–83  ·  view source on GitHub ↗
(cert)

Source from the content-addressed store, hash-verified

66 return [getResource("srvcert.der")];
67 }
68 getKey(cert) {
69 // look for the key corresponding to the cert
70 // first, search in the registed cert
71 for (let i = 0, registeredCerts = this.#registeredCerts.concat(globalCerts); i < registeredCerts.length; i++) {
72 if (0 === Bin.comp(registeredCerts[i], cert)) {
73 const x509 = X509.decode(registeredCerts[i]);
74 return x509.spki; // public key only
75 }
76 }
77
78 // at the moment there is only one key
79 if (this.#clientCertificates[0]) {
80 if (0 === Bin.comp(this.#clientCertificates[0], cert))
81 return PKCS8.parse(new Uint8Array(this.#clientKey));
82 }
83 }
84 findPreferredCert(types, names) {
85 return this.#clientCertificates ?? [];
86 }

Callers 2

unpacketizeFunction · 0.45
packetizeFunction · 0.45

Calls 3

concatMethod · 0.65
decodeMethod · 0.65
parseMethod · 0.65

Tested by

no test coverage detected