End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
Gem::Security.create_key
create_key(algorithm)
lib/rubygems/security.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.1.3/lib/rubygems/security.rb, line 487
def self.create_key(algorithm)
if defined?(OpenSSL::PKey)
case algorithm.downcase
when "dsa"
OpenSSL::PKey::DSA.new(RSA_DSA_KEY_LENGTH)
when "rsa"
OpenSSL::PKey::RSA.new(RSA_DSA_KEY_LENGTH)
when "ec"
if RUBY_VERSION >= "2.4.0"
OpenSSL::PKey::EC.generate(EC_NAME)
else
domain_key = OpenSSL::PKey::EC.new(EC_NAME)
domain_key.generate_key
domain_key
end
else
raise Gem::Security::Exception,
"#{algorithm} algorithm not found. RSA, DSA, and EC algorithms are supported."
end
end
end
Creates a new key pair of the specified algorithm. RSA, DSA, and EC are supported.
See also
.create_digest
.email_to_name
.create_cert_self_signed
.get_public_key
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0