Skip to content

Commit e256703

Browse files
committed
keylimectl: Fix agent add operation
Signed-off-by: Anderson Toshiyuki Sasaki <[email protected]>
1 parent 6d5a5f5 commit e256703

File tree

5 files changed

+253
-64
lines changed

5 files changed

+253
-64
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

keylimectl/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ base64.workspace = true
1717
chrono.workspace = true
1818
clap.workspace = true
1919
config.workspace = true
20+
hex.workspace = true
2021
keylime.workspace = true
2122
log.workspace = true
23+
openssl.workspace = true
2224
pretty_env_logger.workspace = true
2325
reqwest.workspace = true
2426
reqwest-middleware.workspace = true

keylimectl/keylimectl.conf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ port = 8891
6767
# Path to client certificate file for mutual TLS authentication
6868
# Default: None (no client certificate)
6969
# Environment variable: KEYLIME_TLS__CLIENT_CERT
70-
client_cert = "/tmp/certs/client-cert.crt"
70+
client_cert = "/var/lib/keylime/cv_ca/client-cert.crt"
7171

7272
# Path to client private key file for mutual TLS authentication
7373
# Default: None (no client key)
7474
# Environment variable: KEYLIME_TLS__CLIENT_KEY
75-
client_key = "/tmp/certs/client-private.pem"
75+
client_key = "/var/lib/keylime/cv_ca/client-private.pem"
7676

7777
# Password for encrypted client private key (if applicable)
7878
# Default: None (no password)
@@ -82,13 +82,13 @@ client_key = "/tmp/certs/client-private.pem"
8282
# List of trusted CA certificate file paths for server verification
8383
# Default: [] (empty list - uses system CA store)
8484
# Environment variable: KEYLIME_TLS__TRUSTED_CA (comma-separated)
85-
trusted_ca = ["/tmp/certs/cacert.crt"]
85+
trusted_ca = ["/var/lib/keylime/cv_ca/cacert.crt"]
8686

8787
# Whether to verify server certificates
8888
# Default: true
8989
# Environment variable: KEYLIME_TLS__VERIFY_SERVER_CERT
9090
# WARNING: Only disable for testing - never in production!
91-
verify_server_cert = false
91+
verify_server_cert = true
9292

9393
# Whether to enable mutual TLS for agent communications
9494
# Default: true
@@ -228,4 +228,4 @@ max_retries = 3
228228
# 7. ~/.keylimectl.toml (user-specific)
229229
# 8. $XDG_CONFIG_HOME/keylime/keylimectl.conf (XDG standard)
230230
#
231-
# If no configuration files are found, keylimectl works with defaults.
231+
# If no configuration files are found, keylimectl works with defaults.

keylimectl/src/client/base.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,15 @@ impl BaseClient {
165165
}
166166

167167
// Add trusted CA certificates for server verification
168+
debug!(
169+
"Attempting to load {} trusted CA certificate(s)",
170+
config.tls.trusted_ca.len()
171+
);
172+
let mut loaded_cas = 0;
168173
for ca_path in &config.tls.trusted_ca {
174+
debug!("Checking CA certificate: {ca_path}");
169175
if std::path::Path::new(ca_path).exists() {
176+
debug!("CA certificate file exists, attempting to load: {ca_path}");
170177
let ca_cert = std::fs::read(ca_path).map_err(|e| {
171178
ClientError::Tls(TlsError::ca_certificate_file(
172179
ca_path,
@@ -183,10 +190,15 @@ impl BaseClient {
183190
})?;
184191

185192
builder = builder.add_root_certificate(ca_cert);
193+
loaded_cas += 1;
194+
debug!("Successfully loaded CA certificate: {ca_path}");
186195
} else {
187196
warn!("Trusted CA certificate file not found: {ca_path}");
188197
}
189198
}
199+
debug!(
200+
"Loaded {loaded_cas} CA certificate(s) for server verification"
201+
);
190202

191203
// Add client certificate if configured
192204
if let (Some(cert_path), Some(key_path)) =

0 commit comments

Comments
 (0)