Construct a new BlockCaller
object.
ctype
is the C type to be returned
args
are passed the callback
abi
is the abi of the closure
If there is an error in preparing the ffi_cif
or ffi_prep_closure
, then a RuntimeError
will be raised.
include Fiddle cb = Closure::BlockCaller.new(TYPE_INT, [TYPE_INT]) do |one| one end func = Function.new(cb, [TYPE_INT], TYPE_INT)
Creates a new JSON::Ext::Parser
instance for the string source.
Creates a new JSON::Ext::Parser
instance for the string source.
It will be configured by the opts hash. opts can have the following keys:
opts can have the following keys:
max_nesting: The maximum depth of nesting allowed in the parsed data structures. Disable depth checking with :max_nesting => false|nil|0, it defaults to 100.
allow_nan: If set to true, allow NaN, Infinity and -Infinity in defiance of RFC 4627 to be parsed by the Parser
. This option defaults to false.
symbolize_names: If set to true, returns symbols for the names (keys) in a JSON
object. Otherwise strings are returned, which is also the default. It’s not possible to use this option in conjunction with the create_additions option.
create_additions: If set to false, the Parser
doesn’t create additions even if a matching class and create_id was found. This option defaults to false.
object_class: Defaults to Hash
array_class: Defaults to Array
Creates a new instance of OpenSSL::PKey::DH
.
If called without arguments, an empty instance without any parameter or key components is created. Use set_pqg
to manually set the parameters afterwards (and optionally set_key
to set private and public key components).
If a String
is given, tries to parse it as a DER- or PEM- encoded parameters. See also OpenSSL::PKey.read
which can parse keys of any kinds.
The DH.new
(size [, generator]) form is an alias of DH.generate
.
string
A String
that contains the DER or PEM encoded key.
size
See DH.generate
.
generator
See DH.generate
.
Examples:
# Creating an instance from scratch # Note that this is deprecated and will not work on OpenSSL 3.0 or later. dh = OpenSSL::PKey::DH.new dh.set_pqg(bn_p, nil, bn_g) # Generating a parameters and a key pair dh = OpenSSL::PKey::DH.new(2048) # An alias of OpenSSL::PKey::DH.generate(2048) # Reading DH parameters dh_params = OpenSSL::PKey::DH.new(File.read('parameters.pem')) # loads parameters only dh = OpenSSL::PKey.generate_key(dh_params) # generates a key pair
Creates a new DSA
instance by reading an existing key from string.
If called without arguments, creates a new instance with no key components set. They can be set individually by set_pqg
and set_key
.
If called with a String
, tries to parse as DER or PEM encoding of a DSA key. See also OpenSSL::PKey.read
which can parse keys of any kinds.
If called with a number, generates random parameters and a key pair. This form works as an alias of DSA.generate
.
string
A String
that contains a DER or PEM encoded key.
pass
A String
that contains an optional password.
size
See DSA.generate
.
Examples:
p OpenSSL::PKey::DSA.new(1024) #=> #<OpenSSL::PKey::DSA:0x000055a8d6025bf0 oid=DSA> p OpenSSL::PKey::DSA.new(File.read('dsa.pem')) #=> #<OpenSSL::PKey::DSA:0x000055555d6b8110 oid=DSA> p OpenSSL::PKey::DSA.new(File.read('dsa.pem'), 'mypassword') #=> #<OpenSSL::PKey::DSA:0x0000556f973c40b8 oid=DSA>
Creates a new EC
object from given arguments.
Generates or loads an RSA keypair.
If called without arguments, creates a new instance with no key components set. They can be set individually by set_key
, set_factors
, and set_crt_params
.
If called with a String
, tries to parse as DER or PEM encoding of an RSA key. Note that, if passphrase is not specified but the key is encrypted with a passphrase, OpenSSL will prompt for it. See also OpenSSL::PKey.read
which can parse keys of any kinds.
If called with a number, generates a new key pair. This form works as an alias of RSA.generate
.
Examples:
OpenSSL::PKey::RSA.new 2048 OpenSSL::PKey::RSA.new File.read 'rsa.pem' OpenSSL::PKey::RSA.new File.read('rsa.pem'), 'my pass phrase'
Creates a new SSL
context.
If an argument is given, ssl_version=
is called with the value. Note that this form is deprecated. New applications should use min_version=
and max_version=
as necessary.
Creates a new SSL
socket from io which must be a real IO
object (not an IO-like object that responds to read/write).
If ctx is provided the SSL
Sockets initial params will be taken from the context.
The OpenSSL::Buffering
module provides additional IO
methods.
This method will freeze the SSLContext
if one is provided; however, session management is still allowed in the frozen SSLContext
.
Creates a new instance of SSLServer
.
srv is an instance of TCPServer
.
ctx is an instance of OpenSSL::SSL::SSLContext
.
Creates an X509
extension.
The extension may be created from der data or from an extension oid and value. The oid may be either an OID or an extension name. If critical is true
the extension is marked critical.
Creates a new Name
.
A name may be created from a DER encoded string der, an Array
representing a distinguished_name or a distinguished_name along with a template.
name = OpenSSL::X509::Name.new [['CN', 'nobody'], ['DC', 'example']] name = OpenSSL::X509::Name.new name.to_der
See add_entry
for a description of the distinguished_name Array’s contents
Sets up a StoreContext
for a verification of the X.509 certificate cert.
value: Please have a look at Constructive
and Primitive
to see how Ruby types are mapped to ASN.1 types and vice versa.
tag: An Integer
indicating the tag number.
tag_class: A Symbol
indicating the tag class. Please cf. ASN1
for possible values.
asn1_int = OpenSSL::ASN1Data.new(42, 2, :UNIVERSAL) # => Same as OpenSSL::ASN1::Integer.new(42) tagged_int = OpenSSL::ASN1Data.new(42, 0, :CONTEXT_SPECIFIC) # implicitly 0-tagged INTEGER
value: is mandatory.
tag: optional, may be specified for tagged values. If no tag is specified, the UNIVERSAL tag corresponding to the Primitive
sub-class is used by default.
tagging: may be used as an encoding hint to encode a value either explicitly or implicitly, see ASN1
for possible values.
tag_class: if tag and tagging are nil
then this is set to :UNIVERSAL
by default. If either tag or tagging are set then :CONTEXT_SPECIFIC
is used as the default. For possible values please cf. ASN1
.
int = OpenSSL::ASN1::Integer.new(42) zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :IMPLICIT) private_explicit_zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :EXPLICIT, :PRIVATE)
value: is mandatory.
tag: optional, may be specified for tagged values. If no tag is specified, the UNIVERSAL tag corresponding to the Primitive
sub-class is used by default.
tagging: may be used as an encoding hint to encode a value either explicitly or implicitly, see ASN1
for possible values.
tag_class: if tag and tagging are nil
then this is set to :UNIVERSAL
by default. If either tag or tagging are set then :CONTEXT_SPECIFIC
is used as the default. For possible values please cf. ASN1
.
int = OpenSSL::ASN1::Integer.new(42) zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :IMPLICIT) private_explicit_zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :EXPLICIT, :PRIVATE)
request - optional raw request, either in PEM or DER format.
Creates a new OpenSSL::OCSP::Request
. The request may be created empty or from a request_der string.
Creates a new OpenSSL::OCSP::Response
. The response may be created empty or from a response_der string.