Skip to content

Conversation

THardy98
Copy link
Contributor

@THardy98 THardy98 commented Sep 15, 2025

What was changed

Made the TLS disabled field in env config Optional, to reflect it's tri-state:

  • true -> explicitly enabled
  • false -> explicitly disabled
  • None -> not configured

Added a few tests for better e2e coverage

Why?

This representation mimics the TOML configuration when serialized, where as before, disabled would be serialized even if it wasn't set in the TOML config.

@THardy98 THardy98 requested a review from a team as a code owner September 15, 2025 17:15
set_source("client_key", self.client_private_key)
return d

def to_connect_tls_config(self) -> Union[bool, temporalio.service.TLSConfig]:
Copy link
Member

@cretz cretz Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, the default of TLS (i.e. neither true nor false) was that it was implicitly enabled if there was an API key present, otherwise implicitly disabled. I think we need to respect that behavior in the SDKs (IIRC, Go does).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is the behaviour of this function, we only return False (instead of a TLSConfig) if disabled is explicitly enabled

Copy link
Contributor Author

@THardy98 THardy98 Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or are you saying that if a user supplies an api key AND sets disabled to explicitly true, that the api-key would take precedence?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, this case:

        """
        [profile.default]
        address = "{target_host}"
        [profile.default.tls]
        disabled = false
        server_name = "my-server"
        """

technically, TLS is enabled here, there's no restriction as long as don't set disabled as true. We'd basically pass an empty TLSConfig to the client on the connect call

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the test in this commit lays out the various cases:
9423e82

Copy link
Member

@cretz cretz Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue actually is at to_client_connect_config. So if ClientConfigProfile.api_key is present CleintConfigProfile.tls is None, does tls get enabled? It doesn't seem so from the code, but it should.

Copy link
Contributor Author

@THardy98 THardy98 Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done in core:

  /// Apply automatic TLS enabling when API key is present
  pub fn apply_api_key_tls_logic(&mut self) {
      if self.api_key.is_some() && self.tls.is_none() {
          // If API key is present but no TLS config exists, create one with TLS enabled
          self.tls = Some(ClientConfigTLS::default());
      }
  }

though now, given that we have logic in lang to transform to/from object that should represent the TOML, this may no longer be desired/accurate.

Probably the best solution here is to change pub tls: Option<ClientConfigTLS> in core to:

pub enum ConfigTlsEnum {
    Enabled(bool),          // TLS enabled, default options (i.e. api key but no tls)
    Config(ClientConfigTLS), // TLS explicitly configured
}

and then:

pub tls: Option<ConfigTlsEnum> // null is no api key or TLS configuration

alternatively, we keep core as is and make the change upstream in the bridge, with the logic being something like "if received TLS object is ClientConfigTLS::default(), then transform to true"

or we remove apply_api_key_tls_logic from core altogether and have lang implement this logic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am leaning towards the latter, will open a PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@THardy98 THardy98 force-pushed the envconfig_tls_disabled_optional branch from 4e328ed to 9423e82 Compare September 15, 2025 19:17
@THardy98 THardy98 requested a review from cretz September 15, 2025 19:18
@THardy98 THardy98 merged commit 0e1fa4f into main Sep 18, 2025
37 of 40 checks passed
@THardy98 THardy98 deleted the envconfig_tls_disabled_optional branch September 18, 2025 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants