Class: LibTLS::Config
- Inherits:
-
Object
- Object
- LibTLS::Config
- Defined in:
- lib/libtls/config.rb
Overview
A TLS configuration
This object is an abstraction over the libtls configuration. It can be used as a shorthand for configuring the struct tls context.
config = LibTLS::Config.new(
ca_path: '/etc/ssl',
key_mem: [key_ptr, 512]
)
LibTLS::Raw.tls_configure(ctx, config.as_raw)
config.free
Constant Summary collapse
- VALID_SET_CONFIGS =
Keys that can be configured
This is derived from the
tls_config_set_*functions in Raw. i( ca_file ca_path ca_mem cert_file cert_mem ciphers dheparams ecdhecurve key_file key_mem protocols verify_depth )
Instance Method Summary collapse
-
#as_raw ⇒ FFI::Pointer
Convert this object into the C representation.
-
#free ⇒ Object
Release any memory held on to by the C library.
-
#initialize(config_hash) ⇒ Config
constructor
Return a new instance of Config.
Constructor Details
#initialize(config_hash) ⇒ Config
Return a new instance of Config
61 62 63 |
# File 'lib/libtls/config.rb', line 61 def initialize(config_hash) @config_hash = config_hash end |
Instance Method Details
#as_raw ⇒ FFI::Pointer
Convert this object into the C representation
This builds a struct tls_config pointer, sets the values on it as dictated by the hash passed in, and returns the struct tls_config pointer.
The return value must be freed using #free.
76 77 78 |
# File 'lib/libtls/config.rb', line 76 def as_raw @raw_config ||= buld_raw_config end |
#free ⇒ Object
Release any memory held on to by the C library
This method must be called when finished.
84 85 86 |
# File 'lib/libtls/config.rb', line 84 def free LibTLS::Raw.tls_config_free(as_raw) end |