Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

OpenSSL::PKey::RSA.generate

RSA.generate(size) => RSA instance
RSA.generate(size, exponent) => RSA instance

Generates an RSA keypair. size is an integer representing the desired key size. Keys smaller than 1024 should be considered insecure. exponent is an odd number normally 3, 17, or 65537.

See also .new #blinding_off! also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1