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

Add a static property to AmqpTcpEndpoint to specify the default SSL protocol versions and use it on ConnectionFactory.SetUri #389

Merged
merged 2 commits into from
Mar 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using System.Security.Authentication;

#if !NETFX_CORE

Expand Down Expand Up @@ -141,6 +142,18 @@ public class ConnectionFactory : ConnectionFactoryBase, IAsyncConnectionFactory
/// <remarks> PLEASE KEEP THIS MATCHING THE DOC ABOVE.</remarks>
public const string DefaultVHost = "/";

/// <summary>
/// The default AMQP URI SSL protocols.
/// </summary>
public static SslProtocols DefaultAmqpUriSslProtocols { get; set; } =
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

@paulomorgado paulomorgado Mar 15, 2018

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.

Copy link
Member

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.

SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12;

/// <summary>
/// The AMQP URI SSL protocols.
/// </summary>
public SslProtocols AmqpUriSslProtocols { get; set; } =
DefaultAmqpUriSslProtocols;

/// <summary>
/// Default SASL auth mechanisms to use.
/// </summary>
Expand Down Expand Up @@ -517,6 +530,7 @@ private void SetUri(Uri uri)
else if (string.Equals("amqps", uri.Scheme, StringComparison.OrdinalIgnoreCase))
{
Ssl.Enabled = true;
Ssl.Version = AmqpUriSslProtocols;
#if !(NETFX_CORE)
Ssl.AcceptablePolicyErrors = SslPolicyErrors.RemoteCertificateNameMismatch;
#endif
Expand Down