Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pulsar-client] Add support to load tls certs/key dynamically from inputstream #6760

Merged
merged 2 commits into from
Apr 22, 2020

Conversation

rdhabalia
Copy link
Contributor

Motivation

Right now, Pulsar-client provides tls authentication support and default TLS provider AuthenticationTls expects file path of cert and key files. However, there are usescases where it will be difficult for user-applications to store certs/key file locally for tls authentication.
eg:

  1. Applications running on docker or K8s containers will not have certs at defined location and app uses KMS or various key-vault system whose API return streams of certs.
  2. Operationally hard to manage key rotation in containers
  3. Need to avoid storing key/trust store files on file system for stronger security

Therefore, it's good to have mechanism in default AuthenticationTls provider to read certs from memory/stream without storing certs on file-system.

Modification

Add Stream support in AuthenticationTls to provide X509Certs and PrivateKey which also performs auto-refresh when stream changes in a given provider.

AuthenticationTls auth = new AuthenticationTls(certStreamProvider, keyStreamProvider);

It will be also address: #5241

return privateKey;
}

//TODO: check if bufferReader should be closed or not
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fixed it. actually user provided stream can be read multiple times by multiple connections so, pulsar-client needs a stream that can be marked and reset. So, I changed interface with ByteArrayInputStream to support reading same provided stream multiple times.

@sijie
Copy link
Member

sijie commented Apr 20, 2020

/pulsarbot run-failure-checks

@sijie
Copy link
Member

sijie commented Apr 21, 2020

/pulsarbot run-failure-checks

@sijie sijie merged commit 3b48df1 into apache:master Apr 22, 2020
jiazhai pushed a commit that referenced this pull request May 8, 2020
…putstream (#6760)

### Motivation
Right now, Pulsar-client provides tls authentication support and default TLS provider `AuthenticationTls` expects file path of cert and key files. However, there are usescases where it will be difficult for user-applications to store certs/key file locally for tls authentication.
eg:
1. Applications running on docker or K8s containers will not have certs at defined location and app uses KMS or various key-vault system whose API return streams of certs.
2. Operationally hard to manage key rotation in containers
3. Need to avoid storing key/trust store files on file system for stronger security

Therefore, it's good to have mechanism in default `AuthenticationTls` provider to read certs from memory/stream without storing certs on file-system.

### Modification
Add Stream support in `AuthenticationTls` to provide X509Certs and PrivateKey which also performs auto-refresh when stream changes in a given provider.
```
AuthenticationTls auth = new AuthenticationTls(certStreamProvider, keyStreamProvider);
```
It will be also address: #5241
(cherry picked from commit 3b48df1)
huangdx0726 pushed a commit to huangdx0726/pulsar that referenced this pull request Aug 24, 2020
…putstream (apache#6760)

### Motivation
Right now, Pulsar-client provides tls authentication support and default TLS provider `AuthenticationTls` expects file path of cert and key files. However, there are usescases where it will be difficult for user-applications to store certs/key file locally for tls authentication.
eg:
1. Applications running on docker or K8s containers will not have certs at defined location and app uses KMS or various key-vault system whose API return streams of certs.
2. Operationally hard to manage key rotation in containers
3. Need to avoid storing key/trust store files on file system for stronger security

Therefore, it's good to have mechanism in default `AuthenticationTls` provider to read certs from memory/stream without storing certs on file-system.

### Modification
Add Stream support in `AuthenticationTls` to provide X509Certs and PrivateKey which also performs auto-refresh when stream changes in a given provider.
```
AuthenticationTls auth = new AuthenticationTls(certStreamProvider, keyStreamProvider);
```
It will be also address: apache#5241
@rdhabalia rdhabalia deleted the ssl_client_auth branch November 24, 2020 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants