Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
patilms16 opened this issue Mar 22, 2022 · 3 comments

Comments

@patilms16
Copy link

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 as "Digest method not supported" from FileStreamRotator ( which usage crypto submodule of nodejs)

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")

I posted similar question on winston-daily-rotate-file repo (winstonjs/winston-daily-rotate-file#340) , but as this issue seems related to FileStreamRotator and dependent crypto submodule of node, posting the question here.

Also raised same question on stack-overflow : https://stackoverflow.com/questions/71552510/error-digest-method-not-supported-while-using-winston-transports-dailyrotate

Please check below screenshot for openssl version and algorithm list for the platforms where I am using the function ( Please note : for Helios platform function is working fine without any error but for SLES platform it does throw error )

159362257-eb9ee77b-4b12-4882-b975-edaeb66bfd87

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

@rogerc
Copy link
Owner

rogerc commented Mar 24, 2022

@patilms16 try modifying the Winston module to include the option audit_hash_type when getting the stream
https://github.com/winstonjs/winston-daily-rotate-file/blob/a4401b7277353e3375669dae35c0da866cb34e4a/daily-rotate-file.js#L94

If that works, please update the Winston issue you've raised to ask to include that as an option. The line below is from the README

audit_hash_type Use specified hashing algorithm for audit. Defaults to 'md5'. Use 'sha256' for FIPS compliance.

@patilms16
Copy link
Author

patilms16 commented Apr 7, 2022

@rogerc Thanks for the Suggestion.
First of all, I could determine the 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. Then I can use the latest versions.

@patilms16
Copy link
Author

Created a PR in winston-daily-rotate-file to pass audit_hash_type
Created pull request : winstonjs/winston-daily-rotate-file#344

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants