Skip to content

Commit ed9345a

Browse files
committed
ZTIS Support for Kyma
1 parent 48616ac commit ed9345a

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

cloudplatform/connectivity-ztis/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ZeroTrustIdentityService.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class ZeroTrustIdentityService
4747
{
4848
static final ServiceIdentifier ZTIS_IDENTIFIER = ServiceIdentifier.of("zero-trust-identity");
4949
private static final String DEFAULT_SOCKET_PATH = "unix:///tmp/spire-agent/public/api.sock";
50+
private static final String SOCKET_ENVIRONMENT_VARIABLE = "SPIFFE_ENDPOINT_SOCKET";
5051
private static final Duration DEFAULT_SOCKET_TIMEOUT = Duration.ofSeconds(10);
5152
@Getter
5253
private static final ZeroTrustIdentityService instance = new ZeroTrustIdentityService();
@@ -105,17 +106,22 @@ X509Source initX509Source()
105106
return new FileSystemX509Source();
106107
}
107108

109+
final String socketPath = Option.of(System.getenv(SOCKET_ENVIRONMENT_VARIABLE))
110+
.peek(s -> log.debug("Found {} environment variable, using socket path {} for ZTIS agent.", SOCKET_ENVIRONMENT_VARIABLE, s))
111+
.onEmpty(() -> log.warn("Environment variable {} not set, using the default socket path {} for ZTIS agent", SOCKET_ENVIRONMENT_VARIABLE, DEFAULT_SOCKET_PATH))
112+
.getOrElse(DEFAULT_SOCKET_PATH);
113+
108114
final X509SourceOptions x509SourceOptions =
109115
X509SourceOptions
110116
.builder()
111-
.spiffeSocketPath(DEFAULT_SOCKET_PATH)
117+
.spiffeSocketPath(socketPath)
112118
.initTimeout(DEFAULT_SOCKET_TIMEOUT)
113119
.build();
114120
try {
115121
return DefaultX509Source.newSource(x509SourceOptions);
116122
}
117123
catch( final Exception e ) {
118-
throw new CloudPlatformException("Failed to load the certificate from the default unix socket.", e);
124+
throw new CloudPlatformException("Failed to load the certificate from the unix socket: " + socketPath, e);
119125
}
120126
}
121127

release_notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
### ✨ New Functionality
1414

15-
-
15+
- Add support for using the Zero Trust Identity Service (ZTIS) on Kyma by detecting the [well-known environment variable `SPIFFE_ENDPOINT_SOCKET`](https://github.com/spiffe/spiffe/blob/main/standards/SPIFFE_Workload_Endpoint.md#4-locating-the-endpoint).
1616

1717
### 📈 Improvements
1818

0 commit comments

Comments
 (0)