Skip to content

Commit a0e0b2c

Browse files
committed
keylime: Introduce the registrar_client module
The registrar_client module implements the builder pattern to allow setting the optional parameters as needed. This also implements the mechanism to allow the agent to communicate with the registrar that support different API versions: - The client will make a GET request to the '/version' endpoint of the registrar. If the request is successful, the client will use the provided API version if it is enabled. - If the registrar does not support the '/version' endpoint, the client will try to register using each of the enabled API versions, starting from the latest. If none of the enabled versions is supported by the registrar, the registration fails. This is part of the implementation of the enhancement proposal 114: keylime/enhancements#115 Signed-off-by: Anderson Toshiyuki Sasaki <[email protected]>
1 parent 095a836 commit a0e0b2c

File tree

6 files changed

+1508
-12
lines changed

6 files changed

+1508
-12
lines changed

Cargo.lock

+71-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

keylime-agent/src/api.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,13 @@ use crate::{
33
notifications_handler, quotes_handler, QuoteData,
44
};
55
use actix_web::{http, web, HttpRequest, HttpResponse, Responder, Scope};
6-
use keylime::list_parser::parse_list;
6+
use keylime::{list_parser::parse_list, version::KeylimeVersion};
77
use log::*;
88
use serde::{Deserialize, Serialize};
99
use thiserror::Error;
1010

1111
pub static SUPPORTED_API_VERSIONS: &[&str] = &["2.1", "2.2"];
1212

13-
#[derive(Serialize, Deserialize, Debug)]
14-
struct KeylimeVersion {
15-
supported_version: String,
16-
}
17-
1813
#[derive(Error, Debug, PartialEq)]
1914
pub enum APIError {
2015
#[error("API version \"{0}\" not supported")]

keylime/Cargo.toml

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ log.workspace = true
1414
openssl.workspace = true
1515
pest.workspace = true
1616
pest_derive.workspace = true
17+
reqwest.workspace = true
1718
serde.workspace = true
1819
serde_derive.workspace = true
1920
serde_json.workspace = true
@@ -23,11 +24,17 @@ tss-esapi.workspace = true
2324
picky-asn1-der.workspace = true
2425
picky-asn1-x509.workspace = true
2526
tokio.workspace = true
27+
# wiremock was moved to be a regular dependency because optional
28+
# dev-dependencies are not supported
29+
# see: https://github.com/rust-lang/cargo/issues/1596
30+
wiremock = {version = "0.6", optional = true}
2631

2732
[dev-dependencies]
2833
tempfile.workspace = true
34+
actix-rt.workspace = true
2935

3036
[features]
3137
# This feature enables tests that require a TPM and the TCTI environment
3238
# variable properly configured
33-
testing = []
39+
# This should change to dev-dependencies when we have integration testing
40+
testing = ["wiremock"]

keylime/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ pub mod hostname_parser;
55
pub mod ima;
66
pub mod ip_parser;
77
pub mod list_parser;
8+
pub mod registrar_client;
89
pub mod serialization;
910
pub mod tpm;
11+
pub mod version;
1012

1113
#[macro_use]
1214
extern crate static_assertions;

0 commit comments

Comments
 (0)