From c5f94ab646d071f9c4477ef64b62d92d3c741b8d Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 16 Jan 2024 08:40:14 +0200 Subject: [PATCH 1/2] style: change the name to NotarySigningKeyProperties --- notary-server/src/config.rs | 4 ++-- notary-server/src/lib.rs | 2 +- notary-server/src/server.rs | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/notary-server/src/config.rs b/notary-server/src/config.rs index 396984c3cb..b4b0c37267 100644 --- a/notary-server/src/config.rs +++ b/notary-server/src/config.rs @@ -10,7 +10,7 @@ pub struct NotaryServerProperties { /// Setting for TLS connection between prover and notary pub tls: TLSProperties, /// File path of private key (in PEM format) used to sign the notarization - pub notary_signature: NotarySignatureProperties, + pub notary_key: NotarySigningKeyProperties, /// Setting for logging/tracing pub tracing: TracingProperties, /// Setting for authorization @@ -53,7 +53,7 @@ pub struct TLSProperties { #[derive(Clone, Debug, Deserialize)] #[serde(rename_all = "kebab-case")] -pub struct NotarySignatureProperties { +pub struct NotarySigningKeyProperties { pub private_key_pem_path: String, pub public_key_pem_path: String, } diff --git a/notary-server/src/lib.rs b/notary-server/src/lib.rs index e1d2a80384..8a46a574ae 100644 --- a/notary-server/src/lib.rs +++ b/notary-server/src/lib.rs @@ -9,7 +9,7 @@ mod util; pub use config::{ AuthorizationProperties, NotarizationProperties, NotaryServerProperties, - NotarySignatureProperties, ServerProperties, TLSProperties, TracingProperties, + NotarySigningKeyProperties, ServerProperties, TLSProperties, TracingProperties, }; pub use domain::{ cli::CliFields, diff --git a/notary-server/src/server.rs b/notary-server/src/server.rs index 4b3b5ec8da..0e149d6c38 100644 --- a/notary-server/src/server.rs +++ b/notary-server/src/server.rs @@ -28,7 +28,7 @@ use tower::MakeService; use tracing::{debug, error, info}; use crate::{ - config::{NotaryServerProperties, NotarySignatureProperties}, + config::{NotaryServerProperties, NotarySigningKeyProperties}, domain::{ auth::{authorization_whitelist_vec_into_hashmap, AuthorizationWhitelistRecord}, notary::NotaryGlobals, @@ -44,7 +44,7 @@ use crate::{ #[tracing::instrument(skip(config))] pub async fn run_server(config: &NotaryServerProperties) -> Result<(), NotaryServerError> { // Load the private key for notarized transcript signing - let notary_signing_key = load_notary_signing_key(&config.notary_signature).await?; + let notary_signing_key = load_notary_signing_key(&config.notary_key).await?; // Build TLS acceptor if it is turned on let tls_acceptor = if !config.tls.enabled { debug!("Skipping TLS setup as it is turned off."); @@ -105,7 +105,7 @@ pub async fn run_server(config: &NotaryServerProperties) -> Result<(), NotarySer ); // Parameters needed for the info endpoint - let public_key = std::fs::read_to_string(&config.notary_signature.public_key_pem_path) + let public_key = std::fs::read_to_string(&config.notary_key.public_key_pem_path) .map_err(|err| eyre!("Failed to load notary public signing key for notarization: {err}"))?; let version = env!("CARGO_PKG_VERSION").to_string(); let git_commit_hash = env!("GIT_COMMIT_HASH").to_string(); @@ -207,7 +207,7 @@ pub async fn run_server(config: &NotaryServerProperties) -> Result<(), NotarySer } /// Temporary function to load notary signing key from static file -async fn load_notary_signing_key(config: &NotarySignatureProperties) -> Result { +async fn load_notary_signing_key(config: &NotarySigningKeyProperties) -> Result { debug!("Loading notary server's signing key"); let notary_signing_key = SigningKey::read_pkcs8_pem_file(&config.private_key_pem_path) @@ -263,7 +263,7 @@ mod test { #[tokio::test] async fn test_load_notary_signing_key() { - let config = NotarySignatureProperties { + let config = NotarySigningKeyProperties { private_key_pem_path: "./fixture/notary/notary.key".to_string(), public_key_pem_path: "./fixture/notary/notary.pub".to_string(), }; From d49b2be2225523d1ad8a7a47b56c32d45b4da5cc Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 17 Jan 2024 12:39:25 +0200 Subject: [PATCH 2/2] fix test --- notary-server/config/config.yaml | 2 +- notary-server/tests/integration_test.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/notary-server/config/config.yaml b/notary-server/config/config.yaml index 7efd88b268..71d7577fec 100644 --- a/notary-server/config/config.yaml +++ b/notary-server/config/config.yaml @@ -11,7 +11,7 @@ tls: private-key-pem-path: "./fixture/tls/notary.key" certificate-pem-path: "./fixture/tls/notary.crt" -notary-signature: +notary-key: private-key-pem-path: "./fixture/notary/notary.key" public-key-pem-path: "./fixture/notary/notary.pub" diff --git a/notary-server/tests/integration_test.rs b/notary-server/tests/integration_test.rs index 4fa8d1dedc..6aa0e0ca0a 100644 --- a/notary-server/tests/integration_test.rs +++ b/notary-server/tests/integration_test.rs @@ -29,7 +29,7 @@ use ws_stream_tungstenite::WsStream; use notary_server::{ read_pem_file, run_server, AuthorizationProperties, NotarizationProperties, NotarizationSessionRequest, NotarizationSessionResponse, NotaryServerProperties, - NotarySignatureProperties, ServerProperties, TLSProperties, TracingProperties, + NotarySigningKeyProperties, ServerProperties, TLSProperties, TracingProperties, }; const NOTARY_CA_CERT_PATH: &str = "./fixture/tls/rootCA.crt"; @@ -50,7 +50,7 @@ fn get_server_config(port: u16, tls_enabled: bool) -> NotaryServerProperties { private_key_pem_path: "./fixture/tls/notary.key".to_string(), certificate_pem_path: "./fixture/tls/notary.crt".to_string(), }, - notary_signature: NotarySignatureProperties { + notary_key: NotarySigningKeyProperties { private_key_pem_path: "./fixture/notary/notary.key".to_string(), public_key_pem_path: "./fixture/notary/notary.pub".to_string(), },