Skip to content

Commit 011d097

Browse files
committed
added a static property to AmqpTcpEndpoint to specify the default SSL protocol versions and use it on ConnectionFactory.SetUri
1 parent f05ab6e commit 011d097

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

projects/client/RabbitMQ.Client/src/client/api/AmqpTcpEndpoint.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
using System;
4242
using System.Collections.Generic;
43+
using System.Security.Authentication;
4344
using System.Text.RegularExpressions;
4445

4546
namespace RabbitMQ.Client
@@ -62,6 +63,7 @@ public class AmqpTcpEndpoint// : ICloneable
6263
/// </summary>
6364
public const int DefaultAmqpSslPort = 5671;
6465

66+
6567
/// <summary>
6668
/// Indicates that the default port for the protocol should be used.
6769
/// </summary>
@@ -138,6 +140,11 @@ public AmqpTcpEndpoint CloneWithHostname(string hostname)
138140
return new AmqpTcpEndpoint(hostname, _port, Ssl);
139141
}
140142

143+
/// <summary>
144+
/// The default Amqp SSL protocols.
145+
/// </summary>
146+
public static SslProtocols DefaultAmqpSslProtocols { get; set; } = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12;
147+
141148
/// <summary>
142149
/// Retrieve or set the hostname of this <see cref="AmqpTcpEndpoint"/>.
143150
/// </summary>
@@ -174,7 +181,7 @@ public IProtocol Protocol
174181
/// <summary>
175182
/// Used to force the address family of the endpoint
176183
/// </summary>
177-
public System.Net.Sockets.AddressFamily AddressFamily {get; set;}
184+
public System.Net.Sockets.AddressFamily AddressFamily { get; set; }
178185

179186
/// <summary>
180187
/// Retrieve the SSL options for this AmqpTcpEndpoint. If not set, null is returned.
@@ -228,7 +235,7 @@ public static AmqpTcpEndpoint Parse(string address)
228235
/// </remarks>
229236
public static AmqpTcpEndpoint[] ParseMultiple(string addresses)
230237
{
231-
string[] partsArr = addresses.Split(new[] {','});
238+
string[] partsArr = addresses.Split(new[] { ',' });
232239
var results = new List<AmqpTcpEndpoint>();
233240
foreach (string partRaw in partsArr)
234241
{

projects/client/RabbitMQ.Client/src/client/api/ConnectionFactory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ private void SetUri(Uri uri)
517517
else if (string.Equals("amqps", uri.Scheme, StringComparison.OrdinalIgnoreCase))
518518
{
519519
Ssl.Enabled = true;
520+
Ssl.Version = AmqpTcpEndpoint.DefaultAmqpSslProtocols;
520521
#if !(NETFX_CORE)
521522
Ssl.AcceptablePolicyErrors = SslPolicyErrors.RemoteCertificateNameMismatch;
522523
#endif

0 commit comments

Comments
 (0)