End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
DRb::DRbSSLSocket::SSLConfig.new
# File tmp/rubies/ruby-3.0.5/lib/drb/ssl.rb, line 127
def initialize(config)
@config = config
@cert = config[:SSLCertificate]
@pkey = config[:SSLPrivateKey]
@ssl_ctx = nil
end
Create a new DRb::DRbSSLSocket::SSLConfig instance
The DRb::DRbSSLSocket will take either a config Hash or an instance of SSLConfig, and will setup the certificate for its session for the configuration. If want it to generate a generic certificate, the bare minimum is to provide the :SSLCertName
Config options
From config Hash:
- :SSLCertificate
-
An instance of
OpenSSL::X509::Certificate. If this is not provided, then a generic X509 is generated, with a correspond :SSLPrivateKey - :SSLPrivateKey
-
A private key instance, like
OpenSSL::PKey::RSA. This key must be the key that signed the :SSLCertificate - :SSLClientCA
-
An
OpenSSL::X509::Certificate, orArrayof certificates that will used as ClientCAs in the SSL Context - :SSLCACertificatePath
-
A path to the directory of CA certificates. The certificates must be in PEM format.
- :SSLCACertificateFile
-
A path to a CA certificate file, in PEM format.
- :SSLTmpDhCallback
-
A DH callback. See
OpenSSL::SSL::SSLContext.tmp_dh_callback - :SSLVerifyMode
-
This is the SSL verification mode. See OpenSSL::SSL::VERIFY_* for available modes. The default is
OpenSSL::SSL::VERIFY_NONE - :SSLVerifyDepth
-
Number of CA certificates to walk, when verifying a certificate chain.
- :SSLVerifyCallback
-
A callback to be used for additional verification. See
OpenSSL::SSL::SSLContext.verify_callback - :SSLCertificateStore
-
A
OpenSSL::X509::Storeused for verification of certificates - :SSLCertName
-
Issuer name for the certificate. This is required when generating the certificate (if :SSLCertificate and :SSLPrivateKey were not given). The value of this is to be an
Arrayof pairs:Example[["C", "Raleigh"], ["ST","North Carolina"], ["CN","fqdn.example.com"]]
See also
OpenSSL::X509::Name - :SSLCertComment
-
A comment to be used for generating the certificate. The default is “Generated by Ruby/OpenSSL”
Example
These values can be added after the fact, like a Hash.
require 'drb/ssl' c = DRb::DRbSSLSocket::SSLConfig.new {} c[:SSLCertificate] = OpenSSL::X509::Certificate.new(File.read('mycert.crt')) c[:SSLPrivateKey] = OpenSSL::PKey::RSA.new(File.read('mycert.key')) c[:SSLVerifyMode] = OpenSSL::SSL::VERIFY_PEER c[:SSLCACertificatePath] = "/etc/ssl/certs/" c.setup_certificate
or
require 'drb/ssl' c = DRb::DRbSSLSocket::SSLConfig.new({ :SSLCertName => [["CN" => DRb::DRbSSLSocket.getservername]] }) c.setup_certificate