aboutsummaryrefslogtreecommitdiffstats
path: root/zookeeper-common/src/main/java
diff options
context:
space:
mode:
authorHarald Musum <musum@yahooinc.com>2023-12-14 17:42:54 +0100
committerGitHub <noreply@github.com>2023-12-14 17:42:54 +0100
commitb81bedb2aabea0a033023ff5d64857f0b15535bb (patch)
tree90c35a9a1daa6625e684d9f9061c6ff128f32cb0 /zookeeper-common/src/main/java
parent6f0cc5cac45ba97c6365aafde252ff1d1a80f088 (diff)
parentd1f52df9f96ec7375994ff68966daa9217954381 (diff)
Merge pull request #29658 from vespa-engine/jonmv/zk-3.9.1-clients-2
Jonmv/zk 3.9.1 clients 2
Diffstat (limited to 'zookeeper-common/src/main/java')
-rw-r--r--zookeeper-common/src/main/java/com/yahoo/vespa/zookeeper/tls/VespaZookeeperTlsContextUtils.java26
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);
+ }
+
+}