@@ -154,8 +154,9 @@ class HTTPConnectProxyOptions; end # rubocop:disable Lint/EmptyClass
154154 # +localhost:7233+.
155155 # @param api_key [String, nil] API key for Temporal. This becomes the +Authorization+ HTTP header with +"Bearer "+
156156 # prepended. This is only set if RPC metadata doesn't already have an +authorization+ key.
157- # @param tls [Boolean, TLSOptions] If false, do not use TLS. If true, use system default TLS options. If TLS
158- # options are present, those TLS options will be used.
157+ # @param tls [Boolean, TLSOptions, nil] If false, do not use TLS. If true, use system default TLS options. If TLS
158+ # options are present, those TLS options will be used. If nil (the default), TLS will be auto-enabled if
159+ # api_key is provided.
159160 # @param rpc_metadata [Hash<String, String>] Headers to use for all calls to the server. Keys here can be
160161 # overriden by per-call RPC metadata keys.
161162 # @param rpc_retry [RPCRetryOptions] Retry options for direct service calls (when opted in) or all high-level
@@ -173,7 +174,7 @@ class HTTPConnectProxyOptions; end # rubocop:disable Lint/EmptyClass
173174 def initialize (
174175 target_host :,
175176 api_key : nil ,
176- tls : false ,
177+ tls : nil ,
177178 rpc_metadata : { } ,
178179 rpc_retry : RPCRetryOptions . new ,
179180 identity : "#{ Process . pid } @#{ Socket . gethostname } " ,
@@ -285,13 +286,17 @@ def new_core_client
285286 ) ,
286287 identity : @options . identity || "#{ Process . pid } @#{ Socket . gethostname } "
287288 )
288- if @options . tls
289- options . tls = if @options . tls . is_a? ( TLSOptions )
289+ # Auto-enable TLS when API key is provided and tls not explicitly set
290+ tls = @options . tls
291+ tls = true if tls . nil? && @options . api_key
292+
293+ if tls
294+ options . tls = if tls . is_a? ( TLSOptions )
290295 Internal ::Bridge ::Client ::TLSOptions . new (
291- client_cert : @options . tls . client_cert , # steep:ignore
292- client_private_key : @options . tls . client_private_key , # steep:ignore
293- server_root_ca_cert : @options . tls . server_root_ca_cert , # steep:ignore
294- domain : @options . tls . domain # steep:ignore
296+ client_cert : tls . client_cert , # steep:ignore
297+ client_private_key : tls . client_private_key , # steep:ignore
298+ server_root_ca_cert : tls . server_root_ca_cert , # steep:ignore
299+ domain : tls . domain # steep:ignore
295300 )
296301 else
297302 Internal ::Bridge ::Client ::TLSOptions . new
0 commit comments