| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e16a04e commit 513e6aa
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,14 +57,24 @@ const noop = () => {}; | |||
| 57 | 57 | const hasCrypto = Boolean(process.versions.openssl) && | |
| 58 | 58 | !process.env.NODE_SKIP_CRYPTO; | |
| 59 | 59 | ||
| 60 | - const hasOpenSSL3 = hasCrypto && | ||
| 61 | - require('crypto').constants.OPENSSL_VERSION_NUMBER >= 0x30000000; | ||
| 62 | - | ||
| 63 | - const hasOpenSSL31 = hasCrypto && | ||
| 64 | - require('crypto').constants.OPENSSL_VERSION_NUMBER >= 0x30100000; | ||
| 60 | + // Synthesize OPENSSL_VERSION_NUMBER format with the layout 0xMNN00PPSL | ||
| 61 | + const opensslVersionNumber = (major = 0, minor = 0, patch = 0) => { | ||
| 62 | + assert(major >= 0 && major <= 0xf); | ||
| 63 | + assert(minor >= 0 && minor <= 0xff); | ||
| 64 | + assert(patch >= 0 && patch <= 0xff); | ||
| 65 | + return (major << 28) | (minor << 20) | (patch << 4); | ||
| 66 | + }; | ||
| 65 | 67 | ||
| 66 | - const hasOpenSSL32 = hasCrypto && | ||
| 67 | - require('crypto').constants.OPENSSL_VERSION_NUMBER >= 0x30200000; | ||
| 68 | + let OPENSSL_VERSION_NUMBER; | ||
| 69 | + const hasOpenSSL = (major = 0, minor = 0, patch = 0) => { | ||
| 70 | + if (!hasCrypto) return false; | ||
| 71 | + if (OPENSSL_VERSION_NUMBER === undefined) { | ||
| 72 | + const regexp = /(?<m>\d+)\.(?<n>\d+)\.(?<p>\d+)/; | ||
| 73 | + const { m, n, p } = process.versions.openssl.match(regexp).groups; | ||
| 74 | + OPENSSL_VERSION_NUMBER = opensslVersionNumber(m, n, p); | ||
| 75 | + } | ||
| 76 | + return OPENSSL_VERSION_NUMBER >= opensslVersionNumber(major, minor, patch); | ||
| 77 | + }; | ||
| 68 | 78 | ||
| 69 | 79 | const hasQuic = hasCrypto && !!process.config.variables.openssl_quic; | |
| 70 | 80 | ||
@@ -969,9 +979,7 @@ const common = { | |||
| 969 | 979 | getTTYfd, | |
| 970 | 980 | hasIntl, | |
| 971 | 981 | hasCrypto, | |
| 972 | - hasOpenSSL3, | ||
| 973 | - hasOpenSSL31, | ||
| 974 | - hasOpenSSL32, | ||
| 982 | + hasOpenSSL, | ||
| 975 | 983 | hasQuic, | |
| 976 | 984 | hasMultiLocalhost, | |
| 977 | 985 | invalidArgTypeHelper, | |
@@ -1032,6 +1040,18 @@ const common = { | |||
| 1032 | 1040 | }); | |
| 1033 | 1041 | }, | |
| 1034 | 1042 | ||
| 1043 | + get hasOpenSSL3() { | ||
| 1044 | + return hasOpenSSL(3); | ||
| 1045 | + }, | ||
| 1046 | + | ||
| 1047 | + get hasOpenSSL31() { | ||
| 1048 | + return hasOpenSSL(3, 1); | ||
| 1049 | + }, | ||
| 1050 | + | ||
| 1051 | + get hasOpenSSL32() { | ||
| 1052 | + return hasOpenSSL(3, 2); | ||
| 1053 | + }, | ||
| 1054 | + | ||
| 1035 | 1055 | get inFreeBSDJail() { | |
| 1036 | 1056 | if (inFreeBSDJail !== null) return inFreeBSDJail; | |
| 1037 | 1057 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -86,8 +86,8 @@ const crypto = require('crypto'); | |||
| 86 | 86 | } | |
| 87 | 87 | ||
| 88 | 88 | { | |
| 89 | - const v = crypto.constants.OPENSSL_VERSION_NUMBER; | ||
| 90 | - const hasOpenSSL3WithNewErrorMessage = (v >= 0x300000c0 && v <= 0x30100000) || (v >= 0x30100040 && v <= 0x30200000); | ||
| 89 | + const hasOpenSSL3WithNewErrorMessage = (common.hasOpenSSL(3, 0, 12) && !common.hasOpenSSL(3, 1, 1)) || | ||
| 90 | + (common.hasOpenSSL(3, 1, 4) && !common.hasOpenSSL(3, 2, 1)); | ||
| 91 | 91 | assert.throws(() => { | |
| 92 | 92 | dh3.computeSecret(''); | |
| 93 | 93 | }, { message: common.hasOpenSSL3 && !hasOpenSSL3WithNewErrorMessage ? | |
| Back | FazBrowse Home | New Git URL |
0 commit comments