-
Notifications
You must be signed in to change notification settings - Fork 594
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
Add a static property to AmqpTcpEndpoint to specify the default SSL protocol versions and use it on ConnectionFactory.SetUri #389
Add a static property to AmqpTcpEndpoint to specify the default SSL protocol versions and use it on ConnectionFactory.SetUri #389
Conversation
/// <summary> | ||
/// The default Amqp SSL protocols. | ||
/// </summary> | ||
public static SslProtocols DefaultAmqpSslProtocols { get; set; } = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense for this field to be an AmqpTcpEndpoint
field and not, say, ConnectionFactory
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it would make sense to keep global config in the connection factory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my first thought. But than I saw a DefaultAmqpSslPort
in AmqpTcpEndpoint
...
For me, it makes a lot more sense to honor the SSL options already part of ConnectionFactory
when using an URI than having AmqpTcpEndpoint
run free with a mind if its own.
Whst do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move both this field and DefaultAmqpSslPort
to connection factory and bump the version to 5.2.0
. @kjnilsson WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving DefaultAmqpSslPort
to a different class is a breaking change, so a new major is needed if you do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like we have a consensus then? Note that the port property move ideally should be in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Property or constant filed?
And the DefaultAmqpSslProtocols
would still be a static property, right? And with the good defaults, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, what's the verdict?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paulomorgado in this PR, let's move the field to ConnectionFactory
. In a separate one for master, move the port one with a backwards compatible reference. Both @kjnilsson and I are leaning towards using properties for no particular reason, merely as a matter of taste.
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a matter of taste. It's semantic.
I've split SSL protocols settings into static and instance properties and named them to convey the meaning that they will only be used with URIs.
As for the default port, that one can be overridden in the URI and, isn't 5671 the default as 80 is for HTTTP and 443 for HTTPS? If it is, it's pretty fine where it is. System.Uri
has default ports per syntax.
@@ -138,6 +140,11 @@ public AmqpTcpEndpoint CloneWithHostname(string hostname) | |||
return new AmqpTcpEndpoint(hostname, _port, Ssl); | |||
} | |||
|
|||
/// <summary> | |||
/// The default Amqp SSL protocols. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "TLS protocol versions that will be used by default"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is fine and I see no regressions but I'd like to see the field moved to ConnectionFactory
.
/// <summary> | ||
/// The default AMQP URI SSL protocols. | ||
/// </summary> | ||
public static SslProtocols DefaultAmqpUriSslProtocols { get; set; } = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this have a setter? If that's the default, shouldn't it be get-only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case the user want's to change the default globally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this particular property it sounds OK to me to allow for overriding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AmqpUriSslProtocols
would actually be the one overriding the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I agree with @bording: the setter can be dropped. We don't need two ways to override the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intention was to have a wider default that would apply to all connection factories if not changed and a setting for each connection factory.
For instance, I want all connections to be Tls
but I want the connections created from a particular connection factory to be Tls12
.
Otherwise, it doesn't make much chance to have the static property at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, the setter is something we can accept.
Given that one of the new properties is |
Should |
I don't think so. @kjnilsson. That's why I named the properties with AmqpUri. If the user is not using an Uri, then she/he must define every parameter: Nevertheless, |
I've been away for a few days. Any update on this? |
@kjnilsson I'd like to drop one setter and modify a comment. Happy to do that on my own. Let me know if you have any objections. |
… protocol versions and use it on ConnectionFactory.SetUri
…ry as DefaultAmqpUriSslProtocols Added per-instance AmqpUriSslProtocols to ConnectionFactory.
The build is ending in error with
But the PR only touches one .cs file. Why is this failing? |
Maybe we shouldn't provide a default out of the box. Transport Layer Security (TLS) best practices with the .NET Framework |
Not providing a default is usually a very bad idea for libraries. It's not like if you don't provide a default, your users will make an informed decisions or will read the docs. No, some will hack it until it stops complaining and move on. |
The guide says
we don't hardcode it and won't be hardcording it with this PR. And also
I don't think we use So I'm not sure what the argument (and suggested alternative) for "not having a library default" is. Please elaborate? |
We are creating a default for URIs. And in the PR I've set the default for |
Why should it be |
It's my understanding of the recommendation. Am I wrong? What should the default be, than? |
Merging per verbal approval from @kjnilsson. The defaults seem OK for the time being, we may revisit the decision to include TLSv1.0 into the default list within a year. |
What do you mean, @michaelklishin? The default is |
@paulomorgado TLSv1.0 is no longer considered to be suitable for some environments but dropping it would be a breaking change. |
When will this be available on NuGet? |
@paulomorgado we make no promises about GA releases. A new 5.1.x milestone can be released shortly. |
Proposed Changes
When creating a connection from an
Uri
there's no way to specify the accepted TLS versions.Having a property on
AmqpTcpEndpoint
that is used byConnectionFactory.SetUri
would allow users of the library to control the default SSL protocol versions used.Types of Changes
What types of changes does your code introduce to this project?
Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply. You can also fill these out after creatingthe PR. If you're unsure about any of them, don't hesitate to ask on the
mailing list. We're here to help! This is simply a reminder of what we are
going to look for before merging your code.
CONTRIBUTING.md
documentFurther Comments
If this is a relatively large or complex change, kick off the discussion by
explaining why you chose the solution you did and what alternatives you
considered, etc.