dave
02/16/2023, 1:07 AMKatze
02/16/2023, 1:07 AMdave
02/16/2023, 1:07 AMcloudflared tunnel --url http://127.0.0.1:8787
Cyb3r-Jok3
02/16/2023, 1:14 AMdave
02/16/2023, 1:15 AMCyb3r-Jok3
02/16/2023, 1:15 AMdave
02/16/2023, 1:16 AMdave
02/16/2023, 1:31 AMDOMException
in a Workerkian
02/16/2023, 1:46 AMdave
02/16/2023, 1:54 AMpublicKey = await crypto.subtle.importKey('spki', binaryCert, {
name: "RSASSA-PKCS1-v1_5",
hash: "SHA-1"
}, false, ['verify']);
Uncaught Error
dave
02/16/2023, 1:54 AMdave
02/16/2023, 1:54 AMkian
02/16/2023, 1:55 AMkian
02/16/2023, 1:55 AMdave
02/16/2023, 1:55 AMkian
02/16/2023, 1:56 AMdave
02/16/2023, 1:56 AMdave
02/16/2023, 1:57 AMdave
02/16/2023, 1:58 AMSignature Algorithm: sha256WithRSAEncryption
dave
02/16/2023, 2:15 AMdave
02/16/2023, 2:24 AMkian
02/16/2023, 2:28 AMkian
02/16/2023, 2:29 AMdave
02/16/2023, 2:34 AMconst certData = cert.replace(/-+BEGIN CERTIFICATE-+\r?\n?/, '')
.replace(/-+END CERTIFICATE-+\r?\n?/, '')
.replace(/\r\n/g, '\n');
const binaryCert = new TextEncoder().encode(atob(certData)).buffer;
const signatureBuffer = Uint8Array.from(atob(payload.Signature.replace(/-/g, '+').replace(/_/g, '/')), c => c.charCodeAt(0));
console.debug("asdf")
const publicKey = await crypto.subtle.importKey('spki', binaryCert, {
name: signingAlgorithm,
hash: { name: hashAlgorithm }
}, false, ['verify']);
console.debug("asdf")
kian
02/16/2023, 2:35 AMts
function str2ab(str) {
const buf = new ArrayBuffer(str.length);
const bufView = new Uint8Array(buf);
for (let i = 0, strLen = str.length; i < strLen; i++) {
bufView[i] = str.charCodeAt(i);
}
return buf;
}
export default {
async fetch() {
// openssl x509 -pubkey -noout -in ./SimpleNotificationService-56e67fcb41f6fec09b0196692625d385.pem > pubkey.pem
let cert =
"-----BEGIN PUBLIC KEY-----\n" +
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5YzF4g9Y8VUo4F8DVUcQ\n" +
"2pylVpAiPNyyq2VY5ybkw+jt7ZAKpmdnGKPdFKCfI0TuZvUBABJ6I8yz0Zw2b8oD\n" +
"NmF+W+9cRZ0+G2VU9fakJa0jRrgJBnVecjFKoGDU9YwjDXTfT4LEGWFm8PFsvsyT\n" +
"3cm/4yxIY2Ds4GLmg9ymrXBKFR41qNaRCTKU1VQ+WDXLAHpW8EfIBjIqDg0dncYG\n" +
"u/u0Qx3W/BVy6BPlxMH7exn7wJA1GO6VnDPyyKQ2fwR5ks2omE+J3qRmMYAcQCfj\n" +
"SDAfLw3t4oIPKK1RnRCdK6pgoSFxphF9QlKXn1rmNprC+MbnVnRe0CEymqhGngiQ\n" +
"iQIDAQAB\n" +
"-----END PUBLIC KEY-----"
const pk_header = "-----BEGIN PUBLIC KEY-----";
const pk_footer = "-----END PUBLIC KEY-----";
cert = cert.substring(pk_header.length, cert.length - pk_footer.length);
const b64 = atob(cert);
const bin = str2ab(b64);
const key = await crypto.subtle.importKey(
"spki",
bin,
{
name: "RSASSA-PKCS1-v1_5",
hash: "SHA-256",
},
false,
["verify"]
);
return Response.json(key);
},
};
dave
02/16/2023, 2:35 AMkian
02/16/2023, 2:35 AMjson
{"usages":["verify"],"algorithm":{"name":"RSASSA-PKCS1-v1_5","modulusLength":2048,"publicExponent":{},"hash":{"name":"SHA-256"}},"extractable":false,"type":"public"}