Skip to content

Commit 7d39c5a

Browse files
committed
Log more debugging info about certs in Rust
Signed-off-by: James Duong <[email protected]>
1 parent c749b2b commit 7d39c5a

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

glide-core/redis-rs/redis/src/connection.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,19 @@ impl ActualConnection {
606606
ref tls_params,
607607
} => {
608608
let host: &str = host;
609+
610+
// DEBUG: Log TLS connection attempt
611+
println!("CLUSTER TLS DEBUG: Creating TLS connection to {}:{}", host, port);
612+
if let Some(ref params) = tls_params {
613+
if let Some(ref store) = params.root_cert_store {
614+
println!("CLUSTER TLS DEBUG: Root cert store has {} certificates", store.len());
615+
} else {
616+
println!("CLUSTER TLS DEBUG: No root cert store");
617+
}
618+
} else {
619+
println!("CLUSTER TLS DEBUG: No TLS params for {}:{}", host, port);
620+
}
621+
609622
let config = create_rustls_config(insecure, tls_params.as_ref().cloned())?;
610623
let server_name = rustls_pki_types::ServerName::try_from(host)
611624
.map_err(|e| {

glide-core/src/client/mod.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,8 @@ async fn create_cluster_client(
11911191
println!("CLUSTER TLS DEBUG: Certificate stream length: {}", combined_certs.len());
11921192
println!("CLUSTER TLS DEBUG: First 50 bytes: {:?}",
11931193
combined_certs.iter().take(50).collect::<Vec<_>>());
1194+
println!("CLUSTER TLS DEBUG: Last 50 bytes: {:?}",
1195+
combined_certs.iter().rev().take(50).collect::<Vec<_>>());
11941196

11951197
let tls_certs = TlsCertificates {
11961198
client_tls: None,
@@ -1204,7 +1206,17 @@ async fn create_cluster_client(
12041206
let initial_nodes: Vec<_> = request
12051207
.addresses
12061208
.into_iter()
1207-
.map(|address| {
1209+
.enumerate()
1210+
.map(|(i, address)| {
1211+
// DEBUG: Log certificate data for each address
1212+
if let Some(ref params) = tls_params {
1213+
println!("CLUSTER TLS DEBUG: Address {}: {}:{} - TLS params present",
1214+
i, address.host, get_port(&address));
1215+
} else {
1216+
println!("CLUSTER TLS DEBUG: Address {}: {}:{} - No TLS params",
1217+
i, address.host, get_port(&address));
1218+
}
1219+
12081220
get_connection_info(
12091221
&address,
12101222
tls_mode,

utils/remote_cluster_manager.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,11 @@ def start_cluster(
467467
cert_content = f.read()
468468
logging.info(f"Certificate {remote_name} length: {len(cert_content)} bytes")
469469
logging.info(f"Certificate {remote_name} first 100 bytes: {cert_content[:100]}")
470+
logging.info(f"Certificate {remote_name} last 100 bytes: {cert_content[-100:]}")
471+
472+
# Print as hex for exact comparison with Rust output
473+
hex_first = ' '.join(f'{b:02x}' for b in cert_content[:50])
474+
logging.info(f"Certificate {remote_name} first 50 bytes hex: {hex_first}")
470475

471476
# Verify it's valid PEM
472477
if b'-----BEGIN' in cert_content and b'-----END' in cert_content:
@@ -964,6 +969,26 @@ def test_certificates_on_server(self, endpoints: List[str]) -> None:
964969
if line.strip():
965970
logging.info(f" {line}")
966971

972+
# Print raw certificate content for comparison
973+
cert_content_cmd = f"cd {self.remote_repo_path}/utils && wc -c tls_crts/ca.crt && head -c 100 tls_crts/ca.crt && echo && tail -c 100 tls_crts/ca.crt"
974+
returncode, stdout, stderr = self._execute_remote_command(cert_content_cmd, timeout=5)
975+
976+
if returncode == 0:
977+
logging.info("Server certificate raw content:")
978+
for line in stdout.split('\n'):
979+
if line.strip():
980+
logging.info(f" {line}")
981+
982+
# Print certificate as hex for exact comparison
983+
cert_hex_cmd = f"cd {self.remote_repo_path}/utils && xxd -l 100 tls_crts/ca.crt"
984+
returncode, stdout, stderr = self._execute_remote_command(cert_hex_cmd, timeout=5)
985+
986+
if returncode == 0:
987+
logging.info("Server certificate hex (first 100 bytes):")
988+
for line in stdout.split('\n'):
989+
if line.strip():
990+
logging.info(f" {line}")
991+
967992
# Test with a simple Rust program on server
968993
rust_test_program = '''
969994
use std::fs;

0 commit comments

Comments
 (0)