Returns a new DH
instance that carries just the public information, i.e. the prime p
and the generator g
, but no public/private key yet. Such a pair may be generated using DH#generate_key!
. The “public key” needed for a key exchange with DH#compute_key
is considered as per-session information and may be retrieved with DH#pub_key once a key pair has been generated. If the current instance already contains private information (and thus a valid public/private key pair), this information will no longer be present in the new instance generated by DH#public_key
. This feature is helpful for publishing the Diffie-Hellman parameters without leaking any of the private per-session information.
dh = OpenSSL::PKey::DH.new(2048) # has public and private key set public_key = dh.public_key # contains only prime and generator parameters = public_key.to_der # it's safe to publish this
Returns the public key associated with the SPKI
, an instance of OpenSSL::PKey
.
pub
- the public key to be set for this instance
Sets the public key to be associated with the SPKI
, an instance of OpenSSL::PKey
. This should be the public key corresponding to the private key used for signing the SPKI
.
Returns a new DSA
instance that carries just the public key information. If the current instance has also private key information, this will no longer be present in the new instance. This feature is helpful for publishing the public key information without leaking any of the private information.
dsa = OpenSSL::PKey::DSA.new(2048) # has public and private information pub_key = dsa.public_key # has only the public part available pub_key_der = pub_key.to_der # it's safe to publish this
See the OpenSSL
documentation for EC_KEY_get0_public_key()
See the OpenSSL
documentation for EC_KEY_set_public_key()
Returns whether this EC
instance has a public key. The public key (EC::Point
) can be retrieved with EC#public_key
.
Makes new RSA
instance containing the public key from the private key.
Encrypt string
with the public key. padding
defaults to PKCS1_PADDING. The encrypted string output can be decrypted using private_decrypt
.
Decrypt string
, which has been encrypted with the private key, with the public key. padding
defaults to PKCS1_PADDING.
Ensures that :SSLCertificate and :SSLPrivateKey have been provided or that a new certificate is generated with the other parameters provided.
Return the 2 dependency objects that conflicted
Enumerates trusted certificates.
Loads the given certificate_file
Replaces the contents of self
with the contents of other_ary
, truncating or expanding if necessary.
a = [ "a", "b", "c", "d", "e" ] a.replace([ "x", "y", "z" ]) #=> ["x", "y", "z"] a #=> ["x", "y", "z"]
Returns an array with both a numeric
and a big
represented as Bignum objects.
This is achieved by converting numeric
to a Bignum.
A TypeError
is raised if the numeric
is not a Fixnum or Bignum type.
(0x3FFFFFFFFFFFFFFF+1).coerce(42) #=> [42, 4611686018427387904]
Returns the smallest number than or equal to int
in decimal digits (default 0 digits).
Precision may be negative. Returns a floating point number when ndigits
is positive, self
for zero, and ceil up for negative.
1.ceil #=> 1 1.ceil(2) #=> 1.0 15.ceil(-1) #=> 20