summaryrefslogtreecommitdiffstats
path: root/node-admin/src
diff options
context:
space:
mode:
authorMorten Tokle <mortent@yahooinc.com>2023-02-23 12:04:58 +0100
committerAndreas Eriksen <andreer@yahooinc.com>2023-03-02 15:07:40 +0100
commit4823211714d51c538de1362dd68c92c7e5dd86b6 (patch)
tree9782132fcf17170ad2af275edfdf941810f9b593 /node-admin/src
parent337fbe0cef34d6a5c6e12a593b7eea6ec9ad459e (diff)
Use ztsUrl from identity document
Diffstat (limited to 'node-admin/src')
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/identity/AthenzCredentialsMaintainer.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/identity/AthenzCredentialsMaintainer.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/identity/AthenzCredentialsMaintainer.java
index fc49dcc744c..9f3763cf25c 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/identity/AthenzCredentialsMaintainer.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/identity/AthenzCredentialsMaintainer.java
@@ -41,6 +41,7 @@ import java.time.Clock;
import java.time.Duration;
import java.time.Instant;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
@@ -193,7 +194,7 @@ public class AthenzCredentialsMaintainer implements CredentialsMaintainer {
HostnameVerifier ztsHostNameVerifier = useInternalZts
? new AthenzIdentityVerifier(Set.of(configserverIdentity))
: null;
- try (ZtsClient ztsClient = new DefaultZtsClient.Builder(ztsEndpoint).withIdentityProvider(hostIdentityProvider).withHostnameVerifier(ztsHostNameVerifier).build()) {
+ try (ZtsClient ztsClient = new DefaultZtsClient.Builder(ztsEndpoint(doc)).withIdentityProvider(hostIdentityProvider).withHostnameVerifier(ztsHostNameVerifier).build()) {
InstanceIdentity instanceIdentity =
ztsClient.registerInstance(
configserverIdentity,
@@ -206,6 +207,15 @@ public class AthenzCredentialsMaintainer implements CredentialsMaintainer {
}
}
+ /**
+ * Return zts url from identity document, fallback to ztsEndpoint
+ */
+ private URI ztsEndpoint(SignedIdentityDocument doc) {
+ return Optional.ofNullable(doc.ztsUrl())
+ .filter(s -> !s.isBlank())
+ .map(URI::create)
+ .orElse(ztsEndpoint);
+ }
private void refreshIdentity(NodeAgentContext context, ContainerPath privateKeyFile, ContainerPath certificateFile,
ContainerPath identityDocumentFile, SignedIdentityDocument doc) {
KeyPair keyPair = KeyUtils.generateKeypair(KeyAlgorithm.RSA);
@@ -221,7 +231,7 @@ public class AthenzCredentialsMaintainer implements CredentialsMaintainer {
HostnameVerifier ztsHostNameVerifier = useInternalZts
? new AthenzIdentityVerifier(Set.of(configserverIdentity))
: null;
- try (ZtsClient ztsClient = new DefaultZtsClient.Builder(ztsEndpoint).withSslContext(containerIdentitySslContext).withHostnameVerifier(ztsHostNameVerifier).build()) {
+ try (ZtsClient ztsClient = new DefaultZtsClient.Builder(ztsEndpoint(doc)).withSslContext(containerIdentitySslContext).withHostnameVerifier(ztsHostNameVerifier).build()) {
InstanceIdentity instanceIdentity =
ztsClient.refreshInstance(
configserverIdentity,