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

support SSLContext setting in Akka-Http backend #1652

Merged
merged 1 commit into from
Aug 31, 2022

Conversation

dwhjames
Copy link
Contributor

@dwhjames dwhjames commented Aug 7, 2022

mirroring the behavior of the Netty backend

mirroring the behavior of the Netty backend
Copy link
Contributor

@raboof raboof left a comment

Choose a reason for hiding this comment

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

This means if sslContext is set the trustManager setting will be ignored, right?

I think that probably makes sense, but perhaps we should add a validation and throw an error when a user sets both?

@dwhjames
Copy link
Contributor Author

This means if sslContext is set the trustManager setting will be ignored, right?

I think that probably makes sense, but perhaps we should add a validation and throw an error when a user sets both?

Sorry @raboof, I could do with paying closer attention to my notifications 😄 .

I was attempting to mirror the existing behavior

builder = settings.sslContext match {
case Some(sslContext) =>
builder.sslContext(createNettySslContext(sslContext))
case None =>
(settings.trustManager, settings.sslProvider) match {
case (None, None) =>
builder
case (tm, provider) =>
val context = provider match {
case None =>
GrpcSslContexts.configure(SslContextBuilder.forClient())
case Some(sslProvider) =>
GrpcSslContexts.configure(SslContextBuilder.forClient(), sslProvider)
}
builder.sslContext((tm match {
case None => context
case Some(trustManager) => context.trustManager(trustManager)
}).build())


But I take your point that it would be a good safety feature in the config builder to throw an error on ‘ambiguous’ configuration, rather than taking some silent ordering of precedence.
However, my main concern there would be a conflict between loaded config (including defaults) from the resource classpath and then overriding in code, i.e., it might be legitimate to want to use the builder to override rather than just accumulate. Which would mean that you’d need two methods in the builder: one that errors, and one that supplants all prior TLS related config.

Could we leave that for a follow on PR?

@raboof
Copy link
Contributor

raboof commented Aug 31, 2022

This means if sslContext is set the trustManager setting will be ignored, right?
I think that probably makes sense, but perhaps we should add a validation and throw an error when a user sets both?

I was attempting to mirror the existing behavior

builder = settings.sslContext match {
case Some(sslContext) =>
builder.sslContext(createNettySslContext(sslContext))
case None =>
(settings.trustManager, settings.sslProvider) match {
case (None, None) =>
builder
case (tm, provider) =>
val context = provider match {
case None =>
GrpcSslContexts.configure(SslContextBuilder.forClient())
case Some(sslProvider) =>
GrpcSslContexts.configure(SslContextBuilder.forClient(), sslProvider)
}
builder.sslContext((tm match {
case None => context
case Some(trustManager) => context.trustManager(trustManager)
}).build())

But I take your point that it would be a good safety feature in the config builder to throw an error on ‘ambiguous’ configuration, rather than taking some silent ordering of precedence. (...)

Could we leave that for a follow on PR?

Yes, I guess that makes sense.

my main concern there would be a conflict between loaded config (including defaults) from the resource classpath and then overriding in code, i.e., it might be legitimate to want to use the builder to override rather than just accumulate. Which would mean that you’d need two methods in the builder: one that errors, and one that supplants all prior TLS related config.

I'm not sure I understand what you mean here. I agree it's legitimate to want to use the builder to override rather than just accumulate. When an existing GrpcClientSettings object already has a trustManager set, it might not be unreasonable to require the user to explicitly remove that trustManager before setting the sslContext?

@raboof raboof merged commit fd77a92 into akka:main Aug 31, 2022
@raboof
Copy link
Contributor

raboof commented Aug 31, 2022

Could we leave that for a follow on PR?

filed as issue #1674

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants