Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Gem::Security::Signer#sign
sign(data)
lib/rubygems/security/signer.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/security/signer.rb, line 145
def sign(data)
return unless @key
raise Gem::Security::Exception, "no certs provided" if @cert_chain.empty?
if @cert_chain.length == 1 && @cert_chain.last.not_after < Time.now
alert("Your certificate has expired, trying to re-sign it...")
re_sign_key(
expiration_length: (Gem::Security::ONE_DAY * options[:expiration_length_days])
)
end
full_name = extract_name @cert_chain.last
Gem::Security::SigningPolicy.verify @cert_chain, @key, {}, {}, full_name
digest = @digest_algorithm.new if Gem::Security.digest_required?(@key)
@key.sign digest, data
end
Sign data with given digest algorithm