Skip to content

Commit

Permalink
Correcting case of Ssl
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartmcgillivray committed Nov 9, 2023
1 parent 0a93776 commit 7336609
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,25 @@ public class RabbitMqMessageReceived : Activity
public string ConnectionString { get; set; } = default!;


[ActivityInput( Order = 3,Category = PropertyCategories.Configuration)]
public bool EnableSSL { get; set; }
[ActivityInput(
Order = 3,
Category = PropertyCategories.Configuration,
Name = "Enable SSL")]
public bool EnableSsl { get; set; }

[ActivityInput( Order = 4,Category = PropertyCategories.Configuration)]
public string SSLHost { get; set; }
[ActivityInput(
Order = 4,
Category = PropertyCategories.Configuration,
Name = "SSL Host")]
public string SslHost { get; set; }

[ActivityInput(
Order = 5,
Category = PropertyCategories.Configuration,
UIHint = ActivityInputUIHints.CheckList,
DefaultSyntax = SyntaxNames.Json,
Options = new[] { "Ssl2", "Ssl3", "Tls", "Tls11", "Tls12", "Tls13" })]
Options = new[] { "Ssl2", "Ssl3", "Tls", "Tls11", "Tls12", "Tls13" },
Name = "SSL Protocols")]
public HashSet<string> SslProtocols { get; set; } = new() { };

public string ClientId => RabbitMqClientConfigurationHelper.GetClientId(Id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,30 +64,33 @@ public SendRabbitMqMessage(IMessageSenderClientFactory messageSenderClientFactor
[ActivityInput(
Order = 2,
SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid },
Category = PropertyCategories.Configuration)]
public bool EnableSSL { get; set; }
Category = PropertyCategories.Configuration,
Name = "Enable SSL")]
public bool EnableSsl { get; set; }

[ActivityInput(
Order = 3,
SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid },
Category = PropertyCategories.Configuration)]
public string SSLHost { get; set; }
Category = PropertyCategories.Configuration,
Name = "SSL Host")]
public string SslHost { get; set; }

[ActivityInput(
Order = 4,
SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid,SyntaxNames.Json },
Category = PropertyCategories.Configuration,
UIHint = ActivityInputUIHints.CheckList,
DefaultSyntax = SyntaxNames.Json,
Options = new[] { "Ssl2", "Ssl3", "Tls", "Tls11", "Tls12", "Tls13" }
Options = new[] { "Ssl2", "Ssl3", "Tls", "Tls11", "Tls12", "Tls13" },
Name = "SSL Protocols"
)]
public HashSet<string> SslProtocols { get; set; } = new() { };

public string ClientId => RabbitMqClientConfigurationHelper.GetClientId(Id);

protected override async ValueTask<IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context)
{
var config = new RabbitMqBusConfiguration(ConnectionString, ExchangeName, RoutingKey, Headers, ClientId, EnableSSL, SSLHost, SslProtocols);
var config = new RabbitMqBusConfiguration(ConnectionString, ExchangeName, RoutingKey, Headers, ClientId, EnableSsl, SslHost, SslProtocols);

var client = await _messageSenderClientFactory.GetSenderAsync(config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public MessageReceivedBookmark(string exchangeName, string routingKey, string co
RoutingKey = routingKey;
ConnectionString = connectionString;
SslEnabled = sslEnabled;
SSLHost = sslHost;
SslHost = sslHost;
SslProtocols = sslProtocols ?? new List<string>();
Headers = headers ?? new Dictionary<string, string>();
}
Expand All @@ -32,7 +32,7 @@ public MessageReceivedBookmark(string exchangeName, string routingKey, string co
[JsonProperty(Order = 4)]
public bool SslEnabled { get; set; } = default!;
[JsonProperty(Order = 5)]
public string SSLHost { get; set; } = default!;
public string SslHost { get; set; } = default!;
[JsonProperty(Order = 6)]
public Dictionary<string, string> Headers { get; set; } = default!;
[JsonProperty(Order = 7)]
Expand All @@ -50,8 +50,8 @@ public override async ValueTask<IEnumerable<BookmarkResult>> GetBookmarksAsync(B
routingKey: (await context.ReadActivityPropertyAsync(x => x.RoutingKey, cancellationToken))!,
connectionString: (await context.ReadActivityPropertyAsync(x => x.ConnectionString, cancellationToken))!,
headers: (await context.ReadActivityPropertyAsync(x => x.Headers, cancellationToken))!,
sslEnabled:(await context.ReadActivityPropertyAsync(x => x.EnableSSL, cancellationToken))!,
sslHost: (await context.ReadActivityPropertyAsync(x => x.SSLHost, cancellationToken))!,
sslEnabled:(await context.ReadActivityPropertyAsync(x => x.EnableSsl, cancellationToken))!,
sslHost: (await context.ReadActivityPropertyAsync(x => x.SslHost, cancellationToken))!,
sslProtocols: (await context.ReadActivityPropertyAsync(x => x.SslProtocols, cancellationToken))!
))
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class RabbitMqBusConfiguration
public Dictionary<string, string> Headers { get; }
public string ClientId { get; }
public bool AutoDeleteQueue { get; }
public bool EnableSSL { get; }
public bool EnableSsl { get; }
public string SslHost { get; }
public SslProtocols SslProtocols { get; }

Expand All @@ -23,7 +23,7 @@ public RabbitMqBusConfiguration(string connectionString, string exchangeName, st
ExchangeName = exchangeName;
RoutingKey = routingKey;
Headers = headers ?? new Dictionary<string, string>();
EnableSSL = enableSsl;
EnableSsl = enableSsl;
SslHost = sslHost;
SslProtocols = ResolveSslProtocols(sslProtocols ?? Array.Empty<string>());
ClientId = clientId;
Expand Down
4 changes: 2 additions & 2 deletions src/activities/Elsa.Activities.RabbitMq/Services/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void SubscribeWithHandler(Func<TransportMessage, CancellationToken, Task>
{
t.UseRabbitMq(Configuration.ConnectionString, Configuration.ClientId)
.InputQueueOptions(x => x.SetAutoDelete(Configuration.AutoDeleteQueue))
.Ssl(new SslSettings(Configuration.EnableSSL, Configuration.SslHost, version: Configuration.SslProtocols));
.Ssl(new SslSettings(Configuration.EnableSsl, Configuration.SslHost, version: Configuration.SslProtocols));
})
.Start();

Expand All @@ -69,7 +69,7 @@ private void ConfigureAsOneWayClient()
.With(_activator)
.Transport(t => t.UseRabbitMqAsOneWayClient(Configuration.ConnectionString)
.InputQueueOptions(o => o.SetAutoDelete(autoDelete: true))
.Ssl(new SslSettings(Configuration.EnableSSL, Configuration.SslHost, version: Configuration.SslProtocols))
.Ssl(new SslSettings(Configuration.EnableSsl, Configuration.SslHost, version: Configuration.SslProtocols))
)
.Start();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private RabbitMqBusConfiguration CreateConfigurationFromBookmark(MessageReceived
var routingKey = bookmark.RoutingKey;
var headers = bookmark.Headers;
var enableSsl = bookmark.SslEnabled;
var sslHost = bookmark.SSLHost;
var sslHost = bookmark.SslHost;
var sslProtocols = bookmark.SslProtocols;
var clientId = RabbitMqClientConfigurationHelper.GetClientId(activityId);

Expand Down
2 changes: 1 addition & 1 deletion src/activities/Elsa.Activities.RabbitMq/Services/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private async Task TriggerWorkflowsAsync(TransportMessage message, CancellationT

var config = _client.Configuration;

var bookmark = new MessageReceivedBookmark(config.ExchangeName, config.RoutingKey, config.ConnectionString, config.Headers, config.EnableSSL, config.SslHost, config.SslProtocolsString);
var bookmark = new MessageReceivedBookmark(config.ExchangeName, config.RoutingKey, config.ConnectionString, config.Headers, config.EnableSsl, config.SslHost, config.SslProtocolsString);
var launchContext = new WorkflowsQuery(ActivityType, bookmark);

using var scope = _scopeFactory.CreateScope();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ private async IAsyncEnumerable<RabbitMqBusConfiguration> GetConfigurationsAsync(
var routingKey = await activity.EvaluatePropertyValueAsync(x => x.RoutingKey, cancellationToken);
var exchangeName = await activity.EvaluatePropertyValueAsync(x => x.ExchangeName, cancellationToken);
var headers = await activity.EvaluatePropertyValueAsync(x => x.Headers, cancellationToken);
var enableSSL = await activity.EvaluatePropertyValueAsync(x => x.EnableSSL, cancellationToken);
var sslHost = await activity.EvaluatePropertyValueAsync(x => x.SSLHost, cancellationToken);
var enableSSL = await activity.EvaluatePropertyValueAsync(x => x.EnableSsl, cancellationToken);
var sslHost = await activity.EvaluatePropertyValueAsync(x => x.SslHost, cancellationToken);
var sslProtocols = await activity.EvaluatePropertyValueAsync(x => x.SslProtocols, cancellationToken);
var clientId = RabbitMqClientConfigurationHelper.GetTestClientId(activity.ActivityBlueprint.Id);

Expand Down

0 comments on commit 7336609

Please sign in to comment.