diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /toolkit/mozapps/extensions/test/xpcshell/head_cert_handling.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/mozapps/extensions/test/xpcshell/head_cert_handling.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/xpcshell/head_cert_handling.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/xpcshell/head_cert_handling.js b/toolkit/mozapps/extensions/test/xpcshell/head_cert_handling.js new file mode 100644 index 0000000000..08c41a8c7e --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/head_cert_handling.js @@ -0,0 +1,33 @@ +// Helpers for handling certs. +// These are taken from +// https://searchfox.org/mozilla-central/rev/36aa22c7ea92bd3cf7910774004fff7e63341cf5/security/manager/ssl/tests/unit/head_psm.js +// but we don't want to drag that file in here because +// - it conflicts with `head_addons.js`. +// - it has a lot of extra code we don't need. +// So dupe relevant code here. + +// This file will be included along with head_addons.js, use its globals. +/* import-globals-from head_addons.js */ + +"use strict"; + +function readFile(file) { + let fstream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance( + Ci.nsIFileInputStream + ); + fstream.init(file, -1, 0, 0); + let available = fstream.available(); + let data = + available > 0 ? NetUtil.readInputStreamToString(fstream, available) : ""; + fstream.close(); + return data; +} + +function loadCertChain(prefix, names) { + let chain = []; + for (let name of names) { + let filename = `${prefix}_${name}.pem`; + chain.push(readFile(do_get_file(filename))); + } + return chain; +} |