Skip to content

Commit

Permalink
Make ArrowFlightConfig verifyServer true by default
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanCutler committed Feb 7, 2025
1 parent f2edaf9 commit 7613c65
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
public class ArrowFlightConfig
{
private String server;
private Boolean verifyServer;
private boolean verifyServer = true;
private String flightServerSSLCertificate;
private Boolean arrowFlightServerSslEnabled;
private boolean arrowFlightServerSslEnabled;
private Integer arrowFlightPort;

public String getFlightServerName()
Expand All @@ -35,13 +35,13 @@ public ArrowFlightConfig setFlightServerName(String server)
return this;
}

public Boolean getVerifyServer()
public boolean getVerifyServer()
{
return verifyServer;
}

@Config("arrow-flight.server.verify")
public ArrowFlightConfig setVerifyServer(Boolean verifyServer)
public ArrowFlightConfig setVerifyServer(boolean verifyServer)
{
this.verifyServer = verifyServer;
return this;
Expand Down Expand Up @@ -71,13 +71,13 @@ public ArrowFlightConfig setFlightServerSSLCertificate(String flightServerSSLCer
return this;
}

public Boolean getArrowFlightServerSslEnabled()
public boolean getArrowFlightServerSslEnabled()
{
return arrowFlightServerSslEnabled;
}

@Config("arrow-flight.server-ssl-enabled")
public ArrowFlightConfig setArrowFlightServerSslEnabled(Boolean arrowFlightServerSslEnabled)
public ArrowFlightConfig setArrowFlightServerSslEnabled(boolean arrowFlightServerSslEnabled)
{
this.arrowFlightServerSslEnabled = arrowFlightServerSslEnabled;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ public BaseArrowFlightClientHandler(BufferAllocator allocator, ArrowFlightConfig
protected FlightClient createFlightClient()
{
Location location;
if (config.getArrowFlightServerSslEnabled() != null && !config.getArrowFlightServerSslEnabled()) {
location = Location.forGrpcInsecure(config.getFlightServerName(), config.getArrowFlightPort());
if (config.getArrowFlightServerSslEnabled()) {
location = Location.forGrpcTls(config.getFlightServerName(), config.getArrowFlightPort());
}
else {
location = Location.forGrpcTls(config.getFlightServerName(), config.getArrowFlightPort());
location = Location.forGrpcInsecure(config.getFlightServerName(), config.getArrowFlightPort());
}
return createFlightClient(location);
}
Expand All @@ -67,10 +67,8 @@ protected FlightClient createFlightClient(Location location)
try {
Optional<InputStream> trustedCertificate = Optional.empty();
FlightClient.Builder flightClientBuilder = FlightClient.builder(allocator, location);
if (config.getVerifyServer() != null && !config.getVerifyServer()) {
flightClientBuilder.verifyServer(false);
}
else if (config.getFlightServerSSLCertificate() != null) {
flightClientBuilder.verifyServer(config.getVerifyServer());
if (config.getFlightServerSSLCertificate() != null) {
trustedCertificate = Optional.of(newInputStream(Paths.get(config.getFlightServerSSLCertificate())));
flightClientBuilder.trustedCertificates(trustedCertificate.get()).useTls();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ private static DistributedQueryRunner createQueryRunner(
.putAll(catalogProperties)
.put("arrow-flight.server", "localhost")
.put("arrow-flight.server-ssl-enabled", "true")
.put("arrow-flight.server-ssl-certificate", "src/test/resources/server.crt")
.put("arrow-flight.server.verify", "true");
.put("arrow-flight.server-ssl-certificate", "src/test/resources/server.crt");

queryRunner.createCatalog("arrowflight", "arrow-flight", properties.build());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ private static MapType createMapType(Type keyType, Type valueType)
private static FlightClient createFlightClient(BufferAllocator allocator) throws IOException
{
InputStream trustedCertificate = new ByteArrayInputStream(Files.readAllBytes(Paths.get("src/test/resources/server.crt")));
return FlightClient.builder(allocator, getServerLocation()).verifyServer(true).useTls().trustedCertificates(trustedCertificate).build();
return FlightClient.builder(allocator, getServerLocation()).useTls().trustedCertificates(trustedCertificate).build();
}

private void addTableToServer(FlightClient client, VectorSchemaRoot root, String tableName)
Expand Down

0 comments on commit 7613c65

Please sign in to comment.