diff options
author | jonmv <venstad@gmail.com> | 2023-12-17 12:45:29 +0100 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2023-12-17 12:45:29 +0100 |
commit | 5eb199b2b5670458324c4e6073a5a810bee33364 (patch) | |
tree | caf488f7fe3c1d0c4062248d394547384d8ab21c /zookeeper-common/src | |
parent | f9c603a4bb98169c29372e93ebaf8203deb24089 (diff) |
Revert "Merge pull request #29683 from vespa-engine/revert-29678-jonmv/reapply-zk-3.9.1"
This reverts commit c8ece8b229362c7bf725e4433ef4fec86024cd29, reversing
changes made to d42b67f0fe821d122548a345f27fda7f9c9c9d10.
Diffstat (limited to 'zookeeper-common/src')
-rw-r--r-- | zookeeper-common/src/main/java/com/yahoo/vespa/zookeeper/tls/VespaZookeeperTlsContextUtils.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/zookeeper-common/src/main/java/com/yahoo/vespa/zookeeper/tls/VespaZookeeperTlsContextUtils.java b/zookeeper-common/src/main/java/com/yahoo/vespa/zookeeper/tls/VespaZookeeperTlsContextUtils.java new file mode 100644 index 00000000000..78de6c61e17 --- /dev/null +++ b/zookeeper-common/src/main/java/com/yahoo/vespa/zookeeper/tls/VespaZookeeperTlsContextUtils.java @@ -0,0 +1,26 @@ +package com.yahoo.vespa.zookeeper.tls; + +import com.yahoo.security.tls.ConfigFileBasedTlsContext; +import com.yahoo.security.tls.TlsContext; +import com.yahoo.security.tls.TransportSecurityUtils; +import com.yahoo.vespa.defaults.Defaults; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Optional; + +/** + * @author jonmv + */ +public class VespaZookeeperTlsContextUtils { + + private static final Path ZOOKEEPER_TLS_CONFIG_FILE = Path.of(Defaults.getDefaults().underVespaHome("var/zookeeper/conf/tls.conf.json")); + private static final TlsContext tlsContext = Files.exists(ZOOKEEPER_TLS_CONFIG_FILE) + ? new ConfigFileBasedTlsContext(ZOOKEEPER_TLS_CONFIG_FILE, TransportSecurityUtils.getInsecureAuthorizationMode()) + : TransportSecurityUtils.getSystemTlsContext().orElse(null); + + public static Optional<TlsContext> tlsContext() { + return Optional.ofNullable(tlsContext); + } + +} |