Search code examples
node.jswinstonsuse

Error : Digest method not supported while using winston.transports.DailyRotate


Environment :

OS : SUSE Linux Enterprise Server 15 SP2 Node: 14.16.0 Express: 4.17.1, winston: 3.2.1, winston-daily-rotate-file: 4.4.2

I am using following code :

 var transport = new (winston.transports.DailyRotateFile)({
        filename: 'log/server-%DATE%.log',
        datePattern: 'YYYY-MM-DD-HH',
        maxSize: '100m', //100MB
        zippedArchive: true,
        maxFiles: '10',
        frequency: '24h'
    });

and getting error from crypto submodule of nodejs as "Digest method not supported"

Below is actual line which was throwing error from File "FileStreamRotator.js" under node_modules : crypto.createHash('md5').update(logfile + "LOG_FILE" + time).digest("hex")

Can someone please help to identify the issue here and probable solution?

Issue raised in winston-daily-rotate-file (This has been closed as actual issue is in file-stream-rotator and dependent crypto submodule of nodejs ) : https://github.com/winstonjs/winston-daily-rotate-file/issues/340

Raised the question in file-stream-rotator repo : https://github.com/rogerc/file-stream-rotator/issues/90


Solution

  • Root cause of my problem being openssl version used on my platform ( 1.1.1d 10 Sep 2019 ) doesn't support md5. when I try this command "openssl md5 'fileName'" , It throws error : md5 is not a known digest I verified openssl version changelog : Default digest algorithm is changed from md5 to Sha256 Ref: https://www.openssl.org/docs/man1.1.1/man1/dgst.html https://www.openssl.org/news/changelog.html#openssl-111 ( Section : Changes between 1.0.2h and 1.1.0 )

    Next, I verified that version of file-stream-rotator being used in my node_modules is 0.5.7. In this version we don't have audit_hash_type, instead it directly uses 'md5'. However If I change it use different hash type say 'sha256' , I don't get error and it works fine.

    Hence Winston module needs to be updated to include audit_hash_type as an option. This change is available in latest version of winston-daily-rotate-file: https://github.com/winstonjs/winston-daily-rotate-file/releases/tag/v4.7.1