@@ -20,6 +20,19 @@ class Client < DockerEngineRuby::Internal::Transport::BaseClient
2020 ENVIRONMENTS = { production : "http://localhost:2375" , production_tls : "https://localhost:2376" }
2121 # rubocop:enable Style/MutableConstant
2222
23+ # Path to the trusted CA certificate file (PEM) used to verify the Docker daemon
24+ # certificate.
25+ # @return [String, nil]
26+ attr_reader :tls_ca_cert_path
27+
28+ # Path to the client TLS certificate file (PEM).
29+ # @return [String, nil]
30+ attr_reader :tls_client_cert_path
31+
32+ # Path to the client TLS private key file (PEM).
33+ # @return [String, nil]
34+ attr_reader :tls_client_key_path
35+
2336 # @return [DockerEngineRuby::Resources::Auth]
2437 attr_reader :auth
2538
@@ -67,6 +80,15 @@ class Client < DockerEngineRuby::Internal::Transport::BaseClient
6780
6881 # Creates and returns a new client for interacting with the API.
6982 #
83+ # @param tls_ca_cert_path [String, nil] Path to the trusted CA certificate file (PEM) used to verify the Docker daemon
84+ # certificate. Defaults to `ENV["DOCKER_TLS_CA_CERT_PATH"]`
85+ #
86+ # @param tls_client_cert_path [String, nil] Path to the client TLS certificate file (PEM). Defaults to
87+ # `ENV["DOCKER_TLS_CLIENT_CERT_PATH"]`
88+ #
89+ # @param tls_client_key_path [String, nil] Path to the client TLS private key file (PEM). Defaults to
90+ # `ENV["DOCKER_TLS_CLIENT_KEY_PATH"]`
91+ #
7092 # @param environment [:production, :production_tls, nil] Specifies the environment to use for the API.
7193 #
7294 # Each environment maps to a different base URL:
@@ -85,6 +107,9 @@ class Client < DockerEngineRuby::Internal::Transport::BaseClient
85107 #
86108 # @param max_retry_delay [Float]
87109 def initialize (
110+ tls_ca_cert_path : ENV [ "DOCKER_TLS_CA_CERT_PATH" ] ,
111+ tls_client_cert_path : ENV [ "DOCKER_TLS_CLIENT_CERT_PATH" ] ,
112+ tls_client_key_path : ENV [ "DOCKER_TLS_CLIENT_KEY_PATH" ] ,
88113 environment : nil ,
89114 base_url : ENV [ "DOCKER_BASE_URL" ] ,
90115 max_retries : self . class ::DEFAULT_MAX_RETRIES ,
@@ -97,12 +122,19 @@ def initialize(
97122 raise ArgumentError . new ( message )
98123 end
99124
125+ @tls_ca_cert_path = tls_ca_cert_path &.to_s
126+ @tls_client_cert_path = tls_client_cert_path &.to_s
127+ @tls_client_key_path = tls_client_key_path &.to_s
128+
100129 super (
101130 base_url : base_url ,
102131 timeout : timeout ,
103132 max_retries : max_retries ,
104133 initial_retry_delay : initial_retry_delay ,
105- max_retry_delay : max_retry_delay
134+ max_retry_delay : max_retry_delay ,
135+ tls_ca_cert_path : @tls_ca_cert_path ,
136+ tls_client_cert_path : @tls_client_cert_path ,
137+ tls_client_key_path : @tls_client_key_path
106138 )
107139
108140 @auth = DockerEngineRuby ::Resources ::Auth . new ( client : self )
0 commit comments