Class: Temporalio::EnvConfig::ClientConfigTLS

Inherits:
Object
  • Object
show all
Defined in:
lib/temporalio/env_config.rb

Overview

TLS configuration for Temporal client connections.

This class provides methods for creating, serializing, and converting TLS configuration objects used by Temporal clients.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(disabled: nil, server_name: nil, server_root_ca_cert: nil, client_cert: nil, client_private_key: nil) ⇒ ClientConfigTLS

Set default values



49
50
51
52
# File 'lib/temporalio/env_config.rb', line 49

def initialize(disabled: nil, server_name: nil, server_root_ca_cert: nil, client_cert: nil,
               client_private_key: nil)
  super
end

Class Method Details

.from_h(hash) ⇒ ClientConfigTLS?

Create a ClientConfigTLS from a hash

Parameters:

  • hash (Hash, nil)

    Hash representation

Returns:

  • (ClientConfigTLS, nil)

    The TLS configuration or nil if hash is nil/empty



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/temporalio/env_config.rb', line 36

def self.from_h(hash)
  return nil if hash.nil? || hash.empty?

  new(
    disabled: hash[:disabled],
    server_name: hash[:server_name],
    server_root_ca_cert: hash_to_source(hash[:server_ca_cert]),
    client_cert: hash_to_source(hash[:client_cert]),
    client_private_key: hash_to_source(hash[:client_key])
  )
end

Instance Method Details

#to_client_tls_optionsConnection::TLSOptions, false

Create a TLS configuration for use with connections

Returns:

  • (Connection::TLSOptions, false)

    TLS options or false if disabled



68
69
70
71
72
73
74
75
76
77
# File 'lib/temporalio/env_config.rb', line 68

def to_client_tls_options
  return false if disabled

  Client::Connection::TLSOptions.new(
    domain: server_name,
    server_root_ca_cert: read_source(server_root_ca_cert),
    client_cert: read_source(client_cert),
    client_private_key: read_source(client_private_key)
  )
end

#to_hHash

Convert to a hash that can be used for TOML serialization

Returns:

  • (Hash)

    Dictionary representation



56
57
58
59
60
61
62
63
64
# File 'lib/temporalio/env_config.rb', line 56

def to_h
  {
    disabled:,
    server_name:,
    server_ca_cert: server_root_ca_cert ? source_to_hash(server_root_ca_cert) : nil,
    client_cert: client_cert ? source_to_hash(client_cert) : nil,
    client_key: client_private_key ? source_to_hash(client_private_key) : nil
  }.compact
end