Skip to content

Comments

Support InputStream as input for ClientCertificateCredential#15814

Merged
jianghaolu merged 6 commits intoAzure:masterfrom
jianghaolu:cert-cred-input-stream
Oct 5, 2020
Merged

Support InputStream as input for ClientCertificateCredential#15814
jianghaolu merged 6 commits intoAzure:masterfrom
jianghaolu:cert-cred-input-stream

Conversation

@jianghaolu
Copy link
Contributor

Fixes #11243

put("clientId", clientId);
put("tenantId", tenantId);
put("clientCertificate", clientCertificate);
put("clientCertificate", clientCertificate == null ? clientCertificatePath : clientCertificate);
Copy link
Member

Choose a reason for hiding this comment

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

The error message from Validation Util, won't be clear for user.
I think, we should custom handle this with the error message "A certificate source as input stream or file path should be configured on the builder."

We should also throw an exception, if both path and inputstream are configured.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing the error message will break the current certificate path scenario - people may be depending on the error message.

Copy link
Member

Choose a reason for hiding this comment

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

okay, then we should atleast add an additive check for the scenario and throw an exception if both path and inputstream are configured.

@g2vinay g2vinay requested a review from srnagar October 5, 2020 19:48
*/
public ClientCertificateCredentialBuilder pfxCertificate(String certificatePath, String clientCertificatePassword) {
public ClientCertificateCredentialBuilder pfxCertificate(String certificatePath,
String clientCertificatePassword) {
Copy link

@schaabs schaabs Oct 5, 2020

Choose a reason for hiding this comment

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

It seems like we're requiring a password for PFX and not supporting a password for PEM. If we support password protected certificates, I think we should support them by adding a separate property such as Password or CertificatePassword

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Per discussion offline - this will be addressed in a future PR. Issue link coming soon

Copy link

Choose a reason for hiding this comment

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

After discussing this offline, this is something we should address in a subsequent release.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Issue: #15955

@jianghaolu jianghaolu merged commit eb26728 into Azure:master Oct 5, 2020
ClientCertificateCredential(String tenantId, String clientId, String certificatePath, String certificatePassword,
IdentityClientOptions identityClientOptions) {
Objects.requireNonNull(certificatePath, "'certificatePath' cannot be null.");
ClientCertificateCredential(String tenantId, String clientId, String certificatePath, InputStream certificate,
Copy link
Member

Choose a reason for hiding this comment

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

Why do we have both the path to the file and the InputStream? If the inputstream is given, then we don't need the path right? Maybe have separate overloads - one with input stream and one with file path.

Comment on lines +121 to +125
if (clientCertificate != null && clientCertificatePath != null) {
throw logger.logExceptionAsWarning(new IllegalArgumentException("Both certificate input stream and "
+ "certificate path are provided in ClientCertificateCredentialBuilder. Only one of them should "
+ "be provided."));
}
Copy link
Member

Choose a reason for hiding this comment

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

If we are doing this, then maybe the ClientCertificateCredential constructor should only have the input stream arg. If the path is given, the builder can wrap the path with FileInputStream and create the credential instance. This saves multiple if-else checks in ClientCertificateCredential.

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.

[FEATURE REQ] Provide option to load client certificates from InputStream, instead of just String path

4 participants