Skip to content

Commit 99cafa5

Browse files
Introduce two new shovel commands
to be used in case of an emergency.
1 parent b0dd690 commit 99cafa5

File tree

6 files changed

+383
-17
lines changed

6 files changed

+383
-17
lines changed

CHANGELOG.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
11
# rabbitmqadmin-ng Change Log
22

3+
## v2.12.0 (in development)
4+
5+
### Enhancements
6+
7+
* `shovel disable_tls_peer_verification_for_all_source_uris` is a new command that disables TLS peer verification
8+
for all shovel source URIs.
9+
10+
**Important**: this command should **only** be used to undo incorrect shovel source URIs, after a bad deployment, for example,
11+
if [peer verification](https://www.rabbitmq.com/docs/ssl#peer-verification) was enabled before certificates and keys were
12+
deployed.
13+
14+
* `shovel disable_tls_peer_verification_for_all_source_uris` is a new command that disables TLS peer verification
15+
for all shovel source URIs.
16+
17+
**Important**: this command should **only** be used to undo incorrect shovel destination URIs (see above).
18+
319
## v2.11.0 (Sep 22, 2025)
420

521
### Enhancements
622

723
* `federation disable_tls_peer_verification_for_all_upstreams` is a new command that disables TLS peer verification
824
for all federation upstreams.
925

10-
**Important**: this command should **only** be used to undo incorrect federation upstream URI, for example,
11-
if [peer verification](https://www.rabbitmq.com/docs/ssl#peer-verification) was enabled prematurely.
26+
**Important**: this command should **only** be used to correct federation upstream URI after a bad deployment, for example,
27+
if [peer verification](https://www.rabbitmq.com/docs/ssl#peer-verification) was enabled before certificates and keys were
28+
deployed.
1229

1330
### Upgrades
1431

src/cli.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2892,7 +2892,7 @@ pub fn get_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 1] {
28922892
)].map(|cmd| cmd.infer_long_args(pre_flight_settings.infer_long_options))
28932893
}
28942894

2895-
pub fn shovel_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 6] {
2895+
pub fn shovel_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 7] {
28962896
let list_all_cmd = Command::new("list_all")
28972897
.long_about("Lists shovels in all virtual hosts")
28982898
.after_help(color_print::cformat!(
@@ -3043,9 +3043,23 @@ pub fn shovel_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 6
30433043

30443044
let disable_tls_peer_verification_cmd = Command::new("disable_tls_peer_verification_for_all_source_uris")
30453045
// shorter, displayed in the shovels group's help
3046-
.about(color_print::cstr!("<bold><red>Use only in emergency cases</red></bold>. Disables TLS peer verification for all shovels."))
3046+
.about(color_print::cstr!("<bold><red>Use only in case of emergency</red></bold>. Disables TLS peer verification for all shovels."))
30473047
// longer, displayed in the command's help
3048-
.long_about(color_print::cstr!("<bold><red>Use only in emergency cases</red></bold>. Disables TLS peer verification for all shovels by updating their source and destination URIs' 'verify' parameter."))
3048+
.long_about(color_print::cstr!("<bold><red>Use only in case of emergency</red></bold>. Disables TLS peer verification for all shovels by updating their source and destination URIs' 'verify' parameter."))
3049+
.after_help(color_print::cformat!(
3050+
r#"<bold>Doc guides</bold>:
3051+
3052+
* {}
3053+
* {}
3054+
* {}"#,
3055+
SHOVEL_GUIDE_URL,
3056+
TLS_GUIDE_URL,
3057+
"https://www.rabbitmq.com/docs/shovel#tls-connections"
3058+
));
3059+
3060+
let disable_tls_peer_verification_dest_cmd = Command::new("disable_tls_peer_verification_for_all_destination_uris")
3061+
.about(color_print::cstr!("<bold><red>Use only in case of emergency</red></bold>. Disables TLS peer verification for all shovel destination URIs."))
3062+
.long_about(color_print::cstr!("<bold><red>Use only in case of emergency</red></bold>. Disables TLS peer verification for all shovel destination URIs by updating their 'verify' parameter."))
30493063
.after_help(color_print::cformat!(
30503064
r#"<bold>Doc guides</bold>:
30513065
@@ -3064,6 +3078,7 @@ pub fn shovel_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 6
30643078
declare_10_cmd,
30653079
delete_cmd,
30663080
disable_tls_peer_verification_cmd,
3081+
disable_tls_peer_verification_dest_cmd,
30673082
]
30683083
.map(|cmd| cmd.infer_long_args(pre_flight_settings.infer_long_options))
30693084
}
@@ -3404,9 +3419,9 @@ fn federation_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 7
34043419

34053420
let disable_tls_peer_verification_cmd = Command::new("disable_tls_peer_verification_for_all_upstreams")
34063421
// shorter, displayed in the federation group's help
3407-
.about(color_print::cstr!("<bold><red>Use only in emergency cases</red></bold>. Disables TLS peer verification for all federation upstreams."))
3422+
.about(color_print::cstr!("<bold><red>Use only in case of emergency</red></bold>. Disables TLS peer verification for all federation upstreams."))
34083423
// longer, displayed in the command's help
3409-
.long_about(color_print::cstr!("<bold><red>Use only in emergency cases</red></bold>. Disables TLS peer verification for all federation upstreams by updating their 'verify' parameter."))
3424+
.long_about(color_print::cstr!("<bold><red>Use only in case of emergency</red></bold>. Disables TLS peer verification for all federation upstreams by updating their 'verify' parameter."))
34103425

34113426
.after_help(color_print::cformat!(
34123427
r#"<bold>Doc guides</bold>:

src/commands.rs

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -736,34 +736,63 @@ pub fn disable_tls_peer_verification_for_all_federation_upstreams(
736736
pub fn disable_tls_peer_verification_for_all_shovels(
737737
client: APIClient,
738738
) -> Result<(), CommandRunError> {
739-
// Get all runtime parameters of "shovel" component
740739
let all_params = client.list_runtime_parameters()?;
741740
let shovel_params: Vec<_> = all_params
742741
.into_iter()
743742
.filter(|p| p.component == "shovel")
744743
.collect();
745744

746745
for param in shovel_params {
747-
// Convert the runtime parameter to OwnedShovelParams for easier manipulation
748746
let owned_params = match OwnedShovelParams::try_from(param.clone()) {
749747
Ok(params) => params,
750-
Err(_) => continue, // Skip malformed shovel parameters
748+
Err(_) => continue,
751749
};
752750

753751
let original_source_uri = &owned_params.source_uri;
754-
let original_destination_uri = &owned_params.destination_uri;
755752

756-
// Skip shovels with empty URIs
757-
if original_source_uri.is_empty() || original_destination_uri.is_empty() {
753+
if original_source_uri.is_empty() {
758754
continue;
759755
}
760756

761757
let updated_source_uri = disable_tls_peer_verification(original_source_uri)?;
762-
let updated_destination_uri = disable_tls_peer_verification(original_destination_uri)?;
763758

764-
if original_source_uri != &updated_source_uri || original_destination_uri != &updated_destination_uri {
759+
if original_source_uri != &updated_source_uri {
765760
let mut updated_params = owned_params;
766761
updated_params.source_uri = updated_source_uri;
762+
763+
let param = RuntimeParameterDefinition::from(&updated_params);
764+
client.upsert_runtime_parameter(&param)?;
765+
}
766+
}
767+
768+
Ok(())
769+
}
770+
771+
pub fn disable_tls_peer_verification_for_all_destination_uris(
772+
client: APIClient,
773+
) -> Result<(), CommandRunError> {
774+
let all_params = client.list_runtime_parameters()?;
775+
let shovel_params: Vec<_> = all_params
776+
.into_iter()
777+
.filter(|p| p.component == "shovel")
778+
.collect();
779+
780+
for param in shovel_params {
781+
let owned_params = match OwnedShovelParams::try_from(param.clone()) {
782+
Ok(params) => params,
783+
Err(_) => continue,
784+
};
785+
786+
let original_destination_uri = &owned_params.destination_uri;
787+
788+
if original_destination_uri.is_empty() {
789+
continue;
790+
}
791+
792+
let updated_destination_uri = disable_tls_peer_verification(original_destination_uri)?;
793+
794+
if original_destination_uri != &updated_destination_uri {
795+
let mut updated_params = owned_params;
767796
updated_params.destination_uri = updated_destination_uri;
768797

769798
let param = RuntimeParameterDefinition::from(&updated_params);

src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,10 @@ fn dispatch_common_subcommand(
10751075
let result = commands::disable_tls_peer_verification_for_all_shovels(client);
10761076
res_handler.no_output_on_success(result);
10771077
}
1078+
("shovels", "disable_tls_peer_verification_for_all_destination_uris") => {
1079+
let result = commands::disable_tls_peer_verification_for_all_destination_uris(client);
1080+
res_handler.no_output_on_success(result);
1081+
}
10781082
("streams", "declare") => {
10791083
let result = commands::declare_stream(client, &vhost, second_level_args);
10801084
res_handler.no_output_on_success(result);

0 commit comments

Comments
 (0)