Class: Flipt::TlsConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/flipt_client/models.rb

Overview

TlsConfig provides configuration for TLS connections to Flipt servers

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ca_cert_file: nil, ca_cert_data: nil, insecure_skip_verify: nil, insecure_skip_hostname_verify: nil, client_cert_file: nil, client_key_file: nil, client_cert_data: nil, client_key_data: nil) ⇒ TlsConfig

Initialize TLS configuration

Parameters:

  • ca_cert_file (String, nil) (defaults to: nil)

    Path to CA certificate file (PEM format)

  • ca_cert_data (String, nil) (defaults to: nil)

    Raw CA certificate content (PEM format)

  • insecure_skip_verify (Boolean, nil) (defaults to: nil)

    Skip certificate verification (development only)

  • insecure_skip_hostname_verify (Boolean, nil) (defaults to: nil)

    Skip hostname verification while maintaining certificate validation (development only)

  • client_cert_file (String, nil) (defaults to: nil)

    Path to client certificate file (PEM format)

  • client_key_file (String, nil) (defaults to: nil)

    Path to client key file (PEM format)

  • client_cert_data (String, nil) (defaults to: nil)

    Raw client certificate content (PEM format)

  • client_key_data (String, nil) (defaults to: nil)

    Raw client key content (PEM format)



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/flipt_client/models.rb', line 60

def initialize(ca_cert_file: nil, ca_cert_data: nil, insecure_skip_verify: nil,
               insecure_skip_hostname_verify: nil, client_cert_file: nil, client_key_file: nil,
               client_cert_data: nil, client_key_data: nil)
  @ca_cert_file = ca_cert_file
  @ca_cert_data = ca_cert_data
  @insecure_skip_verify = insecure_skip_verify
  @insecure_skip_hostname_verify = insecure_skip_hostname_verify
  @client_cert_file = client_cert_file
  @client_key_file = client_key_file
  @client_cert_data = client_cert_data
  @client_key_data = client_key_data

  validate_files!
end

Instance Attribute Details

#ca_cert_dataObject (readonly)

Returns the value of attribute ca_cert_data.



46
47
48
# File 'lib/flipt_client/models.rb', line 46

def ca_cert_data
  @ca_cert_data
end

#ca_cert_fileObject (readonly)

Returns the value of attribute ca_cert_file.



46
47
48
# File 'lib/flipt_client/models.rb', line 46

def ca_cert_file
  @ca_cert_file
end

#client_cert_dataObject (readonly)

Returns the value of attribute client_cert_data.



46
47
48
# File 'lib/flipt_client/models.rb', line 46

def client_cert_data
  @client_cert_data
end

#client_cert_fileObject (readonly)

Returns the value of attribute client_cert_file.



46
47
48
# File 'lib/flipt_client/models.rb', line 46

def client_cert_file
  @client_cert_file
end

#client_key_dataObject (readonly)

Returns the value of attribute client_key_data.



46
47
48
# File 'lib/flipt_client/models.rb', line 46

def client_key_data
  @client_key_data
end

#client_key_fileObject (readonly)

Returns the value of attribute client_key_file.



46
47
48
# File 'lib/flipt_client/models.rb', line 46

def client_key_file
  @client_key_file
end

#insecure_skip_hostname_verifyObject (readonly)

Returns the value of attribute insecure_skip_hostname_verify.



46
47
48
# File 'lib/flipt_client/models.rb', line 46

def insecure_skip_hostname_verify
  @insecure_skip_hostname_verify
end

#insecure_skip_verifyObject (readonly)

Returns the value of attribute insecure_skip_verify.



46
47
48
# File 'lib/flipt_client/models.rb', line 46

def insecure_skip_verify
  @insecure_skip_verify
end

Class Method Details

.insecureTlsConfig

Deprecated.

Use TlsConfig constructor instead

Create TLS config for insecure connections (development only) WARNING: Only use this in development environments

Returns:

  • (TlsConfig)

    TLS config with certificate verification disabled



80
81
82
# File 'lib/flipt_client/models.rb', line 80

def self.insecure
  new(insecure_skip_verify: true)
end

.with_ca_cert_data(ca_cert_data) ⇒ TlsConfig

Create TLS config with CA certificate data

Parameters:

  • ca_cert_data (String)

    CA certificate content in PEM format

Returns:

  • (TlsConfig)

    TLS config with custom CA certificate



96
97
98
# File 'lib/flipt_client/models.rb', line 96

def self.with_ca_cert_data(ca_cert_data)
  new(ca_cert_data: ca_cert_data)
end

.with_ca_cert_file(ca_cert_file) ⇒ TlsConfig

Create TLS config with CA certificate file

Parameters:

  • ca_cert_file (String)

    Path to CA certificate file

Returns:

  • (TlsConfig)

    TLS config with custom CA certificate



88
89
90
# File 'lib/flipt_client/models.rb', line 88

def self.with_ca_cert_file(ca_cert_file)
  new(ca_cert_file: ca_cert_file)
end

.with_mutual_tls(client_cert_file, client_key_file) ⇒ TlsConfig

Create TLS config for mutual TLS with certificate files

Parameters:

  • client_cert_file (String)

    Path to client certificate file

  • client_key_file (String)

    Path to client key file

Returns:



105
106
107
# File 'lib/flipt_client/models.rb', line 105

def self.with_mutual_tls(client_cert_file, client_key_file)
  new(client_cert_file: client_cert_file, client_key_file: client_key_file)
end

.with_mutual_tls_data(client_cert_data, client_key_data) ⇒ TlsConfig

Create TLS config for mutual TLS with certificate data

Parameters:

  • client_cert_data (String)

    Client certificate content in PEM format

  • client_key_data (String)

    Client key content in PEM format

Returns:



114
115
116
# File 'lib/flipt_client/models.rb', line 114

def self.with_mutual_tls_data(client_cert_data, client_key_data)
  new(client_cert_data: client_cert_data, client_key_data: client_key_data)
end

Instance Method Details

#to_hHash

Convert to hash for JSON serialization

Returns:

  • (Hash)

    TLS configuration as hash



120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/flipt_client/models.rb', line 120

def to_h
  hash = {}
  hash[:ca_cert_file] = @ca_cert_file if @ca_cert_file
  hash[:ca_cert_data] = @ca_cert_data if @ca_cert_data
  hash[:insecure_skip_verify] = @insecure_skip_verify unless @insecure_skip_verify.nil?
  hash[:insecure_skip_hostname_verify] = @insecure_skip_hostname_verify unless @insecure_skip_hostname_verify.nil?
  hash[:client_cert_file] = @client_cert_file if @client_cert_file
  hash[:client_key_file] = @client_key_file if @client_key_file
  hash[:client_cert_data] = @client_cert_data if @client_cert_data
  hash[:client_key_data] = @client_key_data if @client_key_data
  hash
end