Skip to content

Commit

Permalink
Merge pull request #430 from Particular/release-4.4.0
Browse files Browse the repository at this point in the history
Release 4.4.0
  • Loading branch information
adamralph authored Sep 13, 2017
2 parents 30ee175 + ab35c2e commit 6116485
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace NServiceBus
[System.ObsoleteAttribute("Replaced by NServiceBus.Callbacks package. The member currently throws a NotImple" +
"mentedException. Will be removed in version 5.0.0.", true)]
public static NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> DisableCallbackReceiver(this NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> transportExtensions) { }
public static NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> DisableRemoteCertificateValidation(this NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> transportExtensions) { }
public static NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> PrefetchCount(this NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> transportExtensions, ushort prefetchCount) { }
public static NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> PrefetchMultiplier(this NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> transportExtensions, int prefetchMultiplier) { }
public static NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> SetClientCertificates(this NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> transportExtensions, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates) { }
Expand All @@ -27,6 +28,7 @@ namespace NServiceBus
" 5.0.0.", true)]
public static NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> UseConnectionManager<T>(this NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> transportExtensions) { }
public static NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> UseDirectRoutingTopology(this NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> transportExtensions, System.Func<System.Type, string> routingKeyConvention = null, System.Func<string, System.Type, string> exchangeNameConvention = null) { }
public static NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> UseExternalAuthMechanism(this NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> transportExtensions) { }
public static NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> UsePublisherConfirms(this NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> transportExtensions, bool usePublisherConfirms) { }
public static NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> UseRoutingTopology(this NServiceBus.TransportExtensions<NServiceBus.RabbitMQTransport> transportExtensions, System.Func<bool, NServiceBus.Transport.RabbitMQ.IRoutingTopology> topologyFactory) { }
[System.ObsoleteAttribute("Use `RabbitMQTransportSettingsExtensions.UseRoutingTopology(TransportExtensions<R" +
Expand Down
8 changes: 2 additions & 6 deletions src/NServiceBus.RabbitMQ.Tests/RabbitMqContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void SetUp()

var config = ConnectionConfiguration.Create(connectionString, ReceiverQueue);

connectionFactory = new ConnectionFactory(config, null);
connectionFactory = new ConnectionFactory(config, null, false, false);
channelProvider = new ChannelProvider(connectionFactory, routingTopology, true);

messageDispatcher = new MessageDispatcher(channelProvider);
Expand Down Expand Up @@ -61,11 +61,7 @@ public void TearDown()
channelProvider?.Dispose();
}

protected bool TryWaitForMessageReceipt()
{
IncomingMessage message;
return TryReceiveMessage(out message, incomingMessageTimeout);
}
protected bool TryWaitForMessageReceipt() => TryReceiveMessage(out _, incomingMessageTimeout);

protected IncomingMessage ReceiveMessage()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,28 @@ public static TransportExtensions<RabbitMQTransport> SetClientCertificates(this
return transportExtensions;
}

/// <summary>
/// Disables all remote certificate validation when connecting to the broker via TLS.
/// </summary>
/// <param name="transportExtensions"></param>
/// <returns></returns>
public static TransportExtensions<RabbitMQTransport> DisableRemoteCertificateValidation(this TransportExtensions<RabbitMQTransport> transportExtensions)
{
transportExtensions.GetSettings().Set(SettingsKeys.DisableRemoteCertificateValidation, true);
return transportExtensions;
}

/// <summary>
/// Specifies that an external authentication mechanism should be used for client authentication.
/// </summary>
/// <param name="transportExtensions"></param>
/// <returns></returns>
public static TransportExtensions<RabbitMQTransport> UseExternalAuthMechanism(this TransportExtensions<RabbitMQTransport> transportExtensions)
{
transportExtensions.GetSettings().Set(SettingsKeys.UseExternalAuthMechanism, true);
return transportExtensions;
}

/// <summary>
/// Gets the delayed delivery settings.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/NServiceBus.RabbitMQ/Configuration/SettingsKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ static class SettingsKeys
public const string PrefetchMultiplier = "RabbitMQ.PrefetchMultiplier";
public const string PrefetchCount = "RabbitMQ.PrefetchCount";
public const string ClientCertificates = "RabbitMQ.ClientCertificates";
public const string DisableRemoteCertificateValidation = "RabbitMQ.DisableRemoteCertificateValidation";
public const string UseExternalAuthMechanism = "RabbitMQ.UseExternalAuthMechanism";
public const string DisableTimeoutManager = "RabbitMQ.DisableTimeoutManager";
public const string RoutingTopologySupportsDelayedDelivery = "RabbitMQ.RoutingTopologySupportsDelayedDelivery";
}
Expand Down
15 changes: 14 additions & 1 deletion src/NServiceBus.RabbitMQ/Connection/ConnectionFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace NServiceBus.Transport.RabbitMQ
{
using System;
using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using global::RabbitMQ.Client;
Expand All @@ -10,7 +11,7 @@ class ConnectionFactory
readonly global::RabbitMQ.Client.ConnectionFactory connectionFactory;
readonly object lockObject = new object();

public ConnectionFactory(ConnectionConfiguration connectionConfiguration, X509CertificateCollection clientCertificates)
public ConnectionFactory(ConnectionConfiguration connectionConfiguration, X509CertificateCollection clientCertificates, bool disableRemoteCertificateValidation, bool useExternalAuthMechanism)
{
if (connectionConfiguration == null)
{
Expand Down Expand Up @@ -42,6 +43,18 @@ public ConnectionFactory(ConnectionConfiguration connectionConfiguration, X509Ce
connectionFactory.Ssl.Version = SslProtocols.Tls12;
connectionFactory.Ssl.Enabled = connectionConfiguration.UseTls;

if (disableRemoteCertificateValidation)
{
connectionFactory.Ssl.AcceptablePolicyErrors = SslPolicyErrors.RemoteCertificateChainErrors |
SslPolicyErrors.RemoteCertificateNameMismatch |
SslPolicyErrors.RemoteCertificateNotAvailable;
}

if (useExternalAuthMechanism)
{
connectionFactory.AuthMechanisms = new[] { new ExternalMechanismFactory() };
}

connectionFactory.ClientProperties.Clear();

foreach (var item in connectionConfiguration.ClientProperties)
Expand Down
9 changes: 8 additions & 1 deletion src/NServiceBus.RabbitMQ/RabbitMQTransportInfrastructure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ public RabbitMQTransportInfrastructure(SettingsHolder settings, string connectio

X509CertificateCollection clientCertificates;
settings.TryGet(SettingsKeys.ClientCertificates, out clientCertificates);
connectionFactory = new ConnectionFactory(connectionConfiguration, clientCertificates);

bool disableRemoteCertificateValidation;
settings.TryGet(SettingsKeys.DisableRemoteCertificateValidation, out disableRemoteCertificateValidation);

bool useExternalAuthMechanism;
settings.TryGet(SettingsKeys.UseExternalAuthMechanism, out useExternalAuthMechanism);

connectionFactory = new ConnectionFactory(connectionConfiguration, clientCertificates, disableRemoteCertificateValidation, useExternalAuthMechanism);

routingTopology = CreateRoutingTopology();

Expand Down

0 comments on commit 6116485

Please sign in to comment.