Class: Temporalio::EnvConfig::ClientConfigTLS

Inherits:
Data
  • Object
show all
Defined in:
lib/temporalio/env_config.rb,
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.

Instance Attribute Summary collapse

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



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

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

Instance Attribute Details

#client_cert ⇒ Pathname, ... (readonly)

Returns Client certificate source.

Returns:

  • Client certificate source



25
# File 'lib/temporalio/env_config.rb', line 25

ClientConfigTLS = Data.define(:disabled, :server_name, :server_root_ca_cert, :client_cert, :client_private_key)

#client_private_key ⇒ Pathname, ... (readonly)

Returns Client key source.

Returns:

  • Client key source



25
# File 'lib/temporalio/env_config.rb', line 25

ClientConfigTLS = Data.define(:disabled, :server_name, :server_root_ca_cert, :client_cert, :client_private_key)

#disabled ⇒ Boolean? (readonly)

Returns If true, TLS is explicitly disabled; if nil, not specified.

Returns:

  • If true, TLS is explicitly disabled; if nil, not specified



25
# File 'lib/temporalio/env_config.rb', line 25

ClientConfigTLS = Data.define(:disabled, :server_name, :server_root_ca_cert, :client_cert, :client_private_key)

#server_name ⇒ String? (readonly)

Returns SNI override.

Returns:

  • SNI override



25
# File 'lib/temporalio/env_config.rb', line 25

ClientConfigTLS = Data.define(:disabled, :server_name, :server_root_ca_cert, :client_cert, :client_private_key)

#server_root_ca_cert ⇒ Pathname, ... (readonly)

Returns Server CA certificate source.

Returns:

  • Server CA certificate source



25
# File 'lib/temporalio/env_config.rb', line 25

ClientConfigTLS = Data.define(:disabled, :server_name, :server_root_ca_cert, :client_cert, :client_private_key)

Class Method Details

.from_h(hash) ⇒ ClientConfigTLS?

Create a ClientConfigTLS from a hash

Parameters:

  • Hash representation

Returns:

  • The TLS configuration or nil if hash is nil/empty



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

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_options ⇒ Connection::TLSOptions, false

Create a TLS configuration for use with connections

Returns:

  • TLS options or false if disabled



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

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_h ⇒ Hash

Convert to a hash that can be used for TOML serialization

Returns:

  • Dictionary representation



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

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