[ 
https://issues.apache.org/jira/browse/KNOX-3359?focusedWorklogId=1028515&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1028515
 ]

ASF GitHub Bot logged work on KNOX-3359:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/Jul/26 18:21
            Start Date: 07/Jul/26 18:21
    Worklog Time Spent: 10m 
      Work Description: moresandeep commented on code in PR #1291:
URL: https://github.com/apache/knox/pull/1291#discussion_r3538729996


##########
gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/JettySSLService.java:
##########
@@ -132,6 +141,116 @@ private void logAndValidateCertificate(GatewayConfig 
config) throws ServiceLifec
     }
   }
 
+  // Package private for unit test access.
+  // When single-EKU mode is enabled, refuse to start unless:
+  //   - the outbound client-identity keystore is present and holds a usable 
key entry,
+  //   - inbound client authentication is enforced (server truststore + 
client-auth),
+  //   - the outbound HTTP client truststore is configured, and
+  //   - both identities are single-purpose: the client identity carries 
clientAuth (not serverAuth)
+  //     and the server identity carries serverAuth (not clientAuth).
+  // Fail closed: never fall back to the server identity certificate for 
outbound calls, and never
+  // defer a cross-wired/dual-purpose certificate to a runtime handshake 
failure.
+  void validateSingleEkuConfig(GatewayConfig config) throws 
ServiceLifecycleException {
+    // 1. Outbound client-identity keystore must be configured and contain the 
configured key entry.
+    String clientKeystorePath = config.getHttpClientKeystorePath();
+    if (clientKeystorePath == null || clientKeystorePath.isEmpty()) {
+      throw new ServiceLifecycleException("Single-EKU mode is enabled (" + 
GatewayConfig.TLS_SINGLE_EKU_ENABLED
+          + "=true) but the HTTP client keystore path (" + 
GatewayConfig.HTTP_CLIENT_KEYSTORE_PATH
+          + ") is not configured. Server will not start.");
+    }
+    String clientKeyAlias = config.getHttpClientKeyAlias();
+    KeyStore clientKeystore;
+    try {
+      clientKeystore = keystoreService.getKeystoreForHttpClient();
+      if (clientKeystore == null || 
!clientKeystore.isKeyEntry(clientKeyAlias)) {
+        throw new ServiceLifecycleException("Single-EKU mode is enabled but 
the HTTP client keystore at "
+            + clientKeystorePath + " does not contain a key entry for alias '" 
+ clientKeyAlias
+            + "' (" + GatewayConfig.HTTP_CLIENT_KEY_ALIAS + "). Server will 
not start.");
+      }
+    } catch (KeystoreServiceException | KeyStoreException e) {
+      throw new ServiceLifecycleException("Single-EKU mode is enabled but the 
HTTP client keystore at "
+          + clientKeystorePath + " could not be loaded. Server will not 
start.", e);
+    }
+
+    // 2. Inbound client authentication must be enforced (server truststore + 
client-auth).
+    if (config.getTruststorePath() == null) {
+      throw new ServiceLifecycleException("Single-EKU mode is enabled but the 
server truststore ("
+          + GatewayConfig.GATEWAY_TRUSTSTORE_PATH + ") is not configured. 
Server will not start.");
+    }
+    if (!config.isClientAuthNeeded() && !config.isClientAuthWanted()) {

Review Comment:
   Correct.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 1028515)
    Time Spent: 1h 20m  (was: 1h 10m)

> Support Single-Purpose EKU Certificates
> ---------------------------------------
>
>                 Key: KNOX-3359
>                 URL: https://issues.apache.org/jira/browse/KNOX-3359
>             Project: Apache Knox
>          Issue Type: New Feature
>          Components: Server
>            Reporter: Sandeep More
>            Assignee: Sandeep More
>            Priority: Major
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> h1. Background
> Knox currently supports a single certificate per host. This certificate 
> carries both the serverAuth and clientAuth Extended Key Usages (EKUs), 
> meaning the same key and certificate is used whether the service running on 
> the host is acting as a TLS server or as a client in a mutual-TLS (mTLS) 
> handshake.
>  
> Industry standards and public CAs (like DigiCert) are sunsetting multi-use 
> certificates, making Knox's current requirement for dual serverAuth and 
> clientAuth EKUs difficult to manage.
> h1. Overview:
> Knox will need separate keystores and truststores for client authentication 
> and server authentication.
>  # Keystores:
>  * 
>  -- Knox to assert its identity as a server
>  -- Knox to assert its identity as a client (to downstream services)
>        2.Truststores:
>  * 
>  -- Clients asserting identity to Knox
>  -- Servers asserting identity to Knox



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to