webpack: Avoid md4 hash for OpenSSL 3 compatibility

Fedora-36/CentOS/RHEL 9 switched to OpenSSL 3, which does not support
the `md4` hash any more. webpack hardcodes that in a lot of places, so
monkey-patch `crypto.createHash()` to substitute sha256 for md4.

Hack to work around https://github.com/webpack/webpack/issues/13572

Cherry-picked from https://github.com/cockpit-project/starter-kit/commit/3220617fec508

This is solved in current webpack 5 versions, but we don't want to
update this old stable branch to that.
This commit is contained in:
Martin Pitt 2022-07-21 05:01:38 +02:00 committed by Martin Pitt
parent 6ecc2e73f6
commit 561c30cd31

View file

@ -255,6 +255,11 @@ var externals = {
* Implementation
*/
// 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);
var webpack = require("webpack");
var copy = require("copy-webpack-plugin");
var html = require('html-webpack-plugin');