Class: Hatchet::TLSConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/hatchet/config.rb

Overview

TLS configuration for client connections

Examples:

Basic TLS setup

tls = TLSConfig.new(strategy: "tls", server_name: "api.hatchet.com")

Custom certificate setup

tls = TLSConfig.new(
  strategy: "mtls",
  cert_file: "/path/to/client.crt",
  key_file: "/path/to/client.key",
  root_ca_file: "/path/to/ca.crt"
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ TLSConfig

Initialize TLS configuration

Parameters:

  • options (Hash)

    TLS configuration options

Options Hash (**options):

  • :strategy (String)

    TLS strategy (default: “tls”)

  • :cert_file (String)

    Path to client certificate file

  • :key_file (String)

    Path to client private key file

  • :root_ca_file (String)

    Path to root CA certificate file

  • :server_name (String)

    Server name for TLS verification



43
44
45
46
47
48
49
# File 'lib/hatchet/config.rb', line 43

def initialize(**options)
  @strategy = options[:strategy] || env_var("HATCHET_CLIENT_TLS_STRATEGY") || "tls"
  @cert_file = options[:cert_file] || env_var("HATCHET_CLIENT_TLS_CERT_FILE")
  @key_file = options[:key_file] || env_var("HATCHET_CLIENT_TLS_KEY_FILE")
  @root_ca_file = options[:root_ca_file] || env_var("HATCHET_CLIENT_TLS_ROOT_CA_FILE")
  @server_name = options[:server_name] || env_var("HATCHET_CLIENT_TLS_SERVER_NAME") || ""
end

Instance Attribute Details

#cert_fileString?

Returns Path to client certificate file for mTLS.

Returns:

  • (String, nil)

    Path to client certificate file for mTLS



32
# File 'lib/hatchet/config.rb', line 32

attr_accessor :server_name

#key_fileString?

Returns Path to client private key file for mTLS.

Returns:

  • (String, nil)

    Path to client private key file for mTLS



32
# File 'lib/hatchet/config.rb', line 32

attr_accessor :server_name

#root_ca_fileString?

Returns Path to root CA certificate file.

Returns:

  • (String, nil)

    Path to root CA certificate file



32
# File 'lib/hatchet/config.rb', line 32

attr_accessor :server_name

#server_nameString

Returns Server name for TLS verification.

Returns:

  • (String)

    Server name for TLS verification



32
33
34
# File 'lib/hatchet/config.rb', line 32

def server_name
  @server_name
end

#strategyString

Returns TLS strategy (“tls”, “mtls”, “insecure”).

Returns:

  • (String)

    TLS strategy (“tls”, “mtls”, “insecure”)



32
# File 'lib/hatchet/config.rb', line 32

attr_accessor :server_name