webpack: Avoid md4 hash for OpenSSL 3 compatibility

CentOS/RHEL 9 switched to OpenSSL 3, which does not support the `md4`
hash any more. webpack 5 hardcodes that in no less than 21 places, so
monkey-patch `crypto.createHash()` to substitute sha256 for md4.

Hack to work around https://github.com/webpack/webpack/issues/13572
This commit is contained in:
Martin Pitt 2021-09-21 08:33:25 +02:00 committed by Martin Pitt
parent a8e052a78d
commit 3220617fec

View file

@ -8,6 +8,11 @@ const CompressionPlugin = require("compression-webpack-plugin");
const ESLintPlugin = require('eslint-webpack-plugin');
const CockpitPoPlugin = require("./src/lib/cockpit-po-plugin");
// HACK: OpenSSL 3 does not support md4 any more, but webpack hardcodes it all over the place: https://github.com/webpack/webpack/issues/13572
const crypto = require("crypto");
const crypto_orig_createHash = crypto.createHash;
crypto.createHash = algorithm => crypto_orig_createHash(algorithm == "md4" ? "sha256" : algorithm);
const webpack = require("webpack");
const nodedir = path.resolve((process.env.SRCDIR || __dirname), "node_modules");