You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2025/04/22 08:14:43 UTC

(spark-connect-swift) branch main updated: [SPARK-51529] Support `TLS` connections

This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/spark-connect-swift.git


The following commit(s) were added to refs/heads/main by this push:
     new bbc1b6e  [SPARK-51529] Support `TLS` connections
bbc1b6e is described below

commit bbc1b6eccee9a2c8c9ed37aa9192dee0bfdd0db7
Author: Dongjoon Hyun <do...@apache.org>
AuthorDate: Tue Apr 22 17:14:33 2025 +0900

    [SPARK-51529] Support `TLS` connections
    
    ### What changes were proposed in this pull request?
    
    This PR aims to support TLS connections between `Spark Connect Client for Swift` and `Spark Connect Server`.
    
    ### Why are the changes needed?
    
    For feature parity.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Manual review.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No.
    
    Closes #82 from dongjoon-hyun/SPARK-51529.
    
    Authored-by: Dongjoon Hyun <do...@apache.org>
    Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
 Sources/SparkConnect/SparkConnectClient.swift | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/Sources/SparkConnect/SparkConnectClient.swift b/Sources/SparkConnect/SparkConnectClient.swift
index 7794a4e..28f7eba 100644
--- a/Sources/SparkConnect/SparkConnectClient.swift
+++ b/Sources/SparkConnect/SparkConnectClient.swift
@@ -28,6 +28,8 @@ public actor SparkConnectClient {
   let host: String
   let port: Int
   let token: String?
+  var useTLS: Bool = false
+  let transportSecurity: HTTP2ClientTransport.Posix.TransportSecurity
   var intercepters: [ClientInterceptor] = []
   let userContext: UserContext
   var sessionID: String? = nil
@@ -56,6 +58,10 @@ public actor SparkConnectClient {
         token = String(kv[1])
       case URIParams.PARAM_USER_ID:
         userName = String(kv[1])
+      case URIParams.PARAM_USE_SSL:
+        if String(kv[1]).lowercased() == "true" {
+          self.useTLS = true
+        }
       default:
         // Print warning and ignore
         print("Unknown parameter: \(param)")
@@ -65,6 +71,11 @@ public actor SparkConnectClient {
     if let token = self.token {
       self.intercepters.append(BearerTokenInterceptor(token: token))
     }
+    if self.useTLS {
+      self.transportSecurity = .tls
+    } else {
+      self.transportSecurity = .plaintext
+    }
     self.userContext = userName.toUserContext
   }
 
@@ -99,7 +110,7 @@ public actor SparkConnectClient {
     try await withGRPCClient(
       transport: .http2NIOPosix(
         target: .dns(host: self.host, port: self.port),
-        transportSecurity: .plaintext
+        transportSecurity: self.transportSecurity
       ),
       interceptors: self.intercepters
     ) { client in


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org