Skip to content

Commit

Permalink
separate function worker and broker client TLS configuration (apache#…
Browse files Browse the repository at this point in the history
…6602)

Fixes: apache#6521

### Motivation
Separate function worker and broker client TLS configuration
  • Loading branch information
zplinuxlover authored Apr 14, 2020
1 parent 7cffe2a commit 6f9eb5e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
6 changes: 6 additions & 0 deletions conf/functions_worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ tlsAllowInsecureConnection: false
# Tls cert refresh duration in seconds (set 0 to check on every new connection)
tlsCertRefreshCheckDurationSec: 300

############################################
# security settings for pulsar broker client
############################################
# The path to trusted certificates used by the Pulsar client to authenticate with Pulsar brokers
brokerClientTrustCertsFilePath:

########################
# State Management
########################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public class WorkerConfig implements Serializable, PulsarConfiguration {
)
private String tlsKeyFilePath;
@FieldContext(
category = CATEGORY_SECURITY,
category = CATEGORY_WORKER_SECURITY,
doc = "Path for the trusted TLS certificate file"
)
private String tlsTrustCertsFilePath = "";
Expand Down Expand Up @@ -333,6 +333,14 @@ public boolean getTlsEnabled() {
return tlsEnabled || workerPortTls != null;
}

/******** security settings for pulsar broker client **********/

@FieldContext(
category = CATEGORY_CLIENT_SECURITY,
doc = "The path to trusted certificates used by the Pulsar client to authenticate with Pulsar brokers"
)
private String brokerClientTrustCertsFilePath;


/******** Function Runtime configurations **********/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,18 @@ public void start(URI dlogUri,
: workerConfig.getWorkerWebAddress();

if (workerConfig.isAuthenticationEnabled()) {
// for compatible, if user do not define brokerClientTrustCertsFilePath, we will use tlsTrustCertsFilePath,
// otherwise we will use brokerClientTrustCertsFilePath
final String pulsarClientTlsTrustCertsFilePath;
if (StringUtils.isNotBlank(workerConfig.getBrokerClientTrustCertsFilePath())) {
pulsarClientTlsTrustCertsFilePath = workerConfig.getBrokerClientTrustCertsFilePath();
} else {
pulsarClientTlsTrustCertsFilePath = workerConfig.getTlsTrustCertsFilePath();
}

this.brokerAdmin = WorkerUtils.getPulsarAdminClient(workerConfig.getPulsarWebServiceUrl(),
workerConfig.getClientAuthenticationPlugin(), workerConfig.getClientAuthenticationParameters(),
workerConfig.getTlsTrustCertsFilePath(), workerConfig.isTlsAllowInsecureConnection(),
pulsarClientTlsTrustCertsFilePath, workerConfig.isTlsAllowInsecureConnection(),
workerConfig.isTlsHostnameVerificationEnable());

this.functionAdmin = WorkerUtils.getPulsarAdminClient(functionWebServiceUrl,
Expand All @@ -138,7 +147,7 @@ public void start(URI dlogUri,
this.client = WorkerUtils.getPulsarClient(this.workerConfig.getPulsarServiceUrl(),
workerConfig.getClientAuthenticationPlugin(),
workerConfig.getClientAuthenticationParameters(),
workerConfig.isUseTls(), workerConfig.getTlsTrustCertsFilePath(),
workerConfig.isUseTls(), pulsarClientTlsTrustCertsFilePath,
workerConfig.isTlsAllowInsecureConnection(), workerConfig.isTlsHostnameVerificationEnable());
} else {
this.brokerAdmin = WorkerUtils.getPulsarAdminClient(workerConfig.getPulsarWebServiceUrl());
Expand Down

0 comments on commit 6f9eb5e

Please sign in to comment.