ryan-syed commented on code in PR #3380:
URL: https://github.com/apache/arrow-adbc/pull/3380#discussion_r2317399642


##########
csharp/src/Drivers/Apache/Spark/SparkStandardConnection.cs:
##########
@@ -95,19 +99,69 @@ protected override TTransport CreateTransport()
             // Assumption: hostName and port have already been validated.
             Properties.TryGetValue(SparkParameters.HostName, out string? 
hostName);
             Properties.TryGetValue(SparkParameters.Port, out string? port);
+            Properties.TryGetValue(SparkParameters.AuthType, out string? 
authType);
+
+            if (!SparkAuthTypeParser.TryParse(authType, out SparkAuthType 
authTypeValue))
+            {
+                throw new 
ArgumentOutOfRangeException(SparkParameters.AuthType, authType, $"Unsupported 
{SparkParameters.AuthType} value.");
+            }
 
             // Delay the open connection until later.
             bool connectClient = false;
-            TSocketTransport transport = new(hostName!, int.Parse(port!), 
connectClient, config: new());
-            return transport;
+            int portValue = int.Parse(port!);
+
+            // TLS setup
+            TTransport baseTransport;
+            if (TlsOptions.IsTlsEnabled)
+            {
+                X509Certificate2? trustedCert = 
!string.IsNullOrEmpty(TlsOptions.TrustedCertificatePath)
+                    ? new X509Certificate2(TlsOptions.TrustedCertificatePath!)
+                    : null;
+
+                RemoteCertificateValidationCallback certValidator = (sender, 
cert, chain, errors) => HiveServer2TlsImpl.ValidateCertificate(cert, errors, 
TlsOptions);
+
+                if (IPAddress.TryParse(hostName!, out var ipAddress))
+                {
+                    baseTransport = new TTlsSocketTransport(ipAddress, 
portValue, config: new(), 0, trustedCert, certValidator);
+                }
+                else
+                {
+                    baseTransport = new TTlsSocketTransport(hostName!, 
portValue, config: new(), 0, trustedCert, certValidator);
+                }
+            }
+            else
+            {
+                baseTransport = new TSocketTransport(hostName!, portValue, 
connectClient, config: new());
+            }
+            baseTransport = new TSocketTransport(hostName!, portValue, 
connectClient, config: new());

Review Comment:
   Thanks for the catch.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to