Patch #35217

Replace use of Digest::MD5 / Digest::SHA1 with ActiveSupport::Digest

Added by Jens Krämer over 1 year ago. Updated over 1 year ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:


Target version:-


Rails introduced ActiveSupport::Digest to allow central configuration of the actual digest implementation that is used throughout Rails. This is helpful in environments where certain digest implementations (most notably, MD5) are not available, i.e. to be FIPS compliant.

The attached patch replaces all uses of Digest::SHA1 and Digest::MD5 with ActiveSupport::Digest. Without further configuration, this will result in Digest::SHA1 being used in all these instances since that's the current Rails default. This can be changed by users via the config.active_support.hash_digest_class setting , i.e.:

Rails.application.config.active_support.hash_digest_class = OpenSSL::Digest::SHA256

0001-replaces-uses-of-Digest-MD5-and-Digest-SHA1-with-AS-.patch Magnifier (11.1 KB) Jens Krämer, 2021-05-07 05:01


#1 Updated by Pavel Rosický over 1 year ago

thanks for working on this!

however, the OpenID change isn't safe. The SHA1 algorithm is hardcoded here and your change will break it. do support SHA256, maybe add an option to choose it? It has to be a separate option, it can't depend on Rails.application.config.active_support.hash_digest_class

the second missing part is gravatars
as discussed in I don't think there's a way to support this feature without MD5, so if the digest isn't available, the feature has to be disabled.

Also available in: Atom PDF