@@ -156,6 +156,8 @@ public class SpiceClient implements AutoCloseable {
156156 private URI flightAddress ;
157157 private URI httpAddress ;
158158 private int maxRetries ;
159+ private String tlsClientCertFile ;
160+ private String tlsClientKeyFile ;
159161 private FlightSqlClient flightClient ;
160162 private CredentialCallOption authCallOptions = null ;
161163 private BufferAllocator allocator ;
@@ -200,11 +202,18 @@ public static SpiceClientBuilder builder() throws URISyntaxException {
200202 */
201203 public SpiceClient (String appId , String apiKey , URI flightAddress , URI httpAddress , int maxRetries ,
202204 String userAgent , long memoryLimitMB ) {
205+ this (appId , apiKey , flightAddress , httpAddress , maxRetries , userAgent , memoryLimitMB , null , null );
206+ }
207+
208+ public SpiceClient (String appId , String apiKey , URI flightAddress , URI httpAddress , int maxRetries ,
209+ String userAgent , long memoryLimitMB , String tlsClientCertFile , String tlsClientKeyFile ) {
203210 this .appId = appId ;
204211 this .apiKey = apiKey ;
205212 this .maxRetries = maxRetries ;
206213 this .httpAddress = httpAddress ;
207214 this .userAgent = userAgent ;
215+ this .tlsClientCertFile = tlsClientCertFile ;
216+ this .tlsClientKeyFile = tlsClientKeyFile ;
208217
209218 // Arrow Flight requires URI to be grpc protocol, convert http/https for
210219 // convinience
@@ -274,8 +283,14 @@ private synchronized void buildFlightClient() {
274283 NettyChannelBuilder channelBuilder = NettyChannelBuilder .forTarget (target );
275284 if (useTls ) {
276285 try {
286+ var sslContextBuilder = GrpcSslContexts .forClient ();
287+ if (this .tlsClientCertFile != null && this .tlsClientKeyFile != null ) {
288+ sslContextBuilder .keyManager (
289+ new java .io .File (this .tlsClientCertFile ),
290+ new java .io .File (this .tlsClientKeyFile ));
291+ }
277292 channelBuilder .useTransportSecurity ()
278- .sslContext (GrpcSslContexts . forClient () .build ());
293+ .sslContext (sslContextBuilder .build ());
279294 } catch (Exception e ) {
280295 throw new RuntimeException ("Failed to configure TLS for Flight client" , e );
281296 }
0 commit comments