aboutsummaryrefslogtreecommitdiff
path: root/contrib/native/client/example/querySubmitter.cpp
diff options
context:
space:
mode:
authorParth Chandra <parthc@apache.org>2017-07-24 12:55:02 -0700
committerParth Chandra <parthc@apache.org>2017-10-11 19:27:48 -0700
commitf246c3cad7f44baeb8153913052ebc963c62276a (patch)
treee9a9457ae955876e4805f14ed0bc7db1dc253bc4 /contrib/native/client/example/querySubmitter.cpp
parentfacbb92ba319373dd8b8baa171ac1d7978c926c5 (diff)
DRILL-5431: SSL Support (C++) - Update DrillClientImpl to use Channel implementation
Also remove ChannelContextFactory and merge it into ChannelFactory
Diffstat (limited to 'contrib/native/client/example/querySubmitter.cpp')
-rw-r--r--contrib/native/client/example/querySubmitter.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/contrib/native/client/example/querySubmitter.cpp b/contrib/native/client/example/querySubmitter.cpp
index 47e55de2d..43b909d26 100644
--- a/contrib/native/client/example/querySubmitter.cpp
+++ b/contrib/native/client/example/querySubmitter.cpp
@@ -1,4 +1,3 @@
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -25,7 +24,7 @@
#include <boost/algorithm/string/join.hpp>
#include "drill/drillc.hpp"
-int nOptions=19;
+int nOptions=25;
struct Option{
char name[32];
@@ -50,7 +49,14 @@ struct Option{
{"service_host", "Service host for Kerberos", false},
{"service_name", "Service name for Kerberos", false},
{"auth", "Authentication mechanism to use", false},
- {"sasl_encrypt", "Negotiate for encrypted connection", false}
+ {"sasl_encrypt", "Negotiate for encrypted connection", false},
+ {"enableSSL", "Enable SSL", false},
+ {"TLSProtocol", "TLS protocol version", false},
+ {"certFilePath", "Path to SSL certificate file", false},
+ {"disableHostnameVerification", "disable host name verification", false},
+ {"disableCertVerification", "disable certificate verification", false},
+ {"useSystemTrustStore", "[Windows only]. Use the system truststore.", false }
+
};
std::map<std::string, std::string> qsOptionValues;
@@ -304,6 +310,12 @@ int main(int argc, char* argv[]) {
std::string serviceHost=qsOptionValues["service_host"];
std::string serviceName=qsOptionValues["service_name"];
std::string auth=qsOptionValues["auth"];
+ std::string enableSSL=qsOptionValues["enableSSL"];
+ std::string tlsProtocol=qsOptionValues["TLSProtocol"];
+ std::string certFilePath=qsOptionValues["certFilePath"];
+ std::string disableHostnameVerification=qsOptionValues["disableHostnameVerification"];
+ std::string disableCertVerification=qsOptionValues["disableCertVerification"];
+ std::string useSystemTrustStore = qsOptionValues["useSystemTrustStore"];
Drill::QueryType type;
@@ -392,6 +404,20 @@ int main(int argc, char* argv[]) {
if(auth.length()>0){
props.setProperty(USERPROP_AUTH_MECHANISM, auth);
}
+ if(enableSSL.length()>0){
+ props.setProperty(USERPROP_USESSL, enableSSL);
+ if (enableSSL == "true" && certFilePath.length() <= 0 && useSystemTrustStore.length() <= 0){
+ std::cerr<< "SSL is enabled but no certificate or truststore provided. " << std::endl;
+ return -1;
+ }
+ props.setProperty(USERPROP_TLSPROTOCOL, tlsProtocol);
+ props.setProperty(USERPROP_CERTFILEPATH, certFilePath);
+ props.setProperty(USERPROP_DISABLE_HOSTVERIFICATION, disableHostnameVerification);
+ props.setProperty(USERPROP_DISABLE_CERTVERIFICATION, disableCertVerification);
+ if (useSystemTrustStore.length() > 0){
+ props.setProperty(USERPROP_USESYSTEMTRUSTSTORE, useSystemTrustStore);
+ }
+ }
if(client.connect(connectStr.c_str(), &props)!=Drill::CONN_SUCCESS){
std::cerr<< "Failed to connect with error: "<< client.getError() << " (Using:"<<connectStr<<")"<<std::endl;
@@ -548,3 +574,4 @@ int main(int argc, char* argv[]) {
return 0;
}
+