[njs] Tests: adapted WebCrypto tests to RHEL9.

Dmitry Volyntsev xeioex at nginx.com
Tue May 24 05:27:40 UTC 2022


details:   https://hg.nginx.org/njs/rev/169f20b8a3e8
branches:  
changeset: 1863:169f20b8a3e8
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Mon May 23 22:26:51 2022 -0700
description:
Tests: adapted WebCrypto tests to RHEL9.

diffstat:

 test/webcrypto/sign.t.js   |  12 +++++++++++-
 test/webcrypto/verify.t.js |  12 +++++++++++-
 2 files changed, 22 insertions(+), 2 deletions(-)

diffs (44 lines):

diff -r 98959158fe23 -r 169f20b8a3e8 test/webcrypto/sign.t.js
--- a/test/webcrypto/sign.t.js	Mon May 23 22:26:50 2022 -0700
+++ b/test/webcrypto/sign.t.js	Mon May 23 22:26:51 2022 -0700
@@ -11,7 +11,17 @@ async function test(params) {
                                                  false, [ "sign" ]);
 
     let sig = await crypto.subtle.sign(params.sign_alg, sign_key,
-                                     encoder.encode(params.text));
+                                     encoder.encode(params.text))
+                    .catch (e => {
+                        if (e.toString().startsWith("Error: EVP_PKEY_CTX_set_signature_md() failed")) {
+                            /* Red Hat Enterprise Linux: SHA-1 is disabled */
+                            return "SKIPPED";
+                        }
+                    });
+
+    if (sig == "SKIPPED") {
+        return sig;
+    }
 
     if (params.verify) {
         let verify_key = await crypto.subtle.importKey(params.verify_key.fmt,
diff -r 98959158fe23 -r 169f20b8a3e8 test/webcrypto/verify.t.js
--- a/test/webcrypto/verify.t.js	Mon May 23 22:26:50 2022 -0700
+++ b/test/webcrypto/verify.t.js	Mon May 23 22:26:51 2022 -0700
@@ -11,7 +11,17 @@ async function test(params) {
 
     let r = await crypto.subtle.verify(params.verify_alg,
                                        key, params.signature,
-                                       params.text);
+                                       params.text)
+                    .catch (e => {
+                        if (e.toString().startsWith("Error: EVP_PKEY_CTX_set_signature_md() failed")) {
+                            /* Red Hat Enterprise Linux: SHA-1 is disabled */
+                            return "SKIPPED";
+                        }
+                    });
+
+    if (r == "SKIPPED") {
+        return r;
+    }
 
     if (params.expected !== r) {
         throw Error(`${params.import_alg.name} failed expected: "${params.expected}" vs "${r}"`);



More information about the nginx-devel mailing list