We did a bundle update recently that went wrong. As we understood, the support for 'digest/hmac' dropped, so I wanted to use OpenSSL instead:
OLD [WORKING] CODE:
def signature(str)
key = EnvHelpers.google_oauth2_hmac_key
Digest::HMAC.hexdigest(str, key, Digest::SHA2)
end
NEW CODE:
def signature(str)
key = EnvHelpers.google_oauth2_hmac_key
OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha2"), key, str)
end
When we run rspec:
Failure/Error: OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha2"), key, str)
RuntimeError:
Unsupported digest algorithm (sha2).: first num too large
Relevant parts of the Gemfile:
ruby "2.3.3"
gem "openssl", require: true # Gemfile.lock says I am at (2.0.3)
We are opened to any suggestion to resolve the problem. This part of the code is mostly used for our Google and Facebook connection flow.