diff --git a/p11nethsm.conf b/p11nethsm.conf index 7d401aea..85a79c3f 100644 --- a/p11nethsm.conf +++ b/p11nethsm.conf @@ -15,4 +15,4 @@ slots: danger_insecure_cert: true # sha256_fingerprints: # - "31:92:8E:A4:5E:16:5C:A7:33:44:E8:E9:8E:64:C4:AE:7B:2A:57:E5:77:43:49:F3:69:C9:8F:C4:2F:3A:3B:6E" - \ No newline at end of file + # timeout: 10 diff --git a/pkcs11/src/config/config_file.rs b/pkcs11/src/config/config_file.rs index 8793c572..8f8371b1 100644 --- a/pkcs11/src/config/config_file.rs +++ b/pkcs11/src/config/config_file.rs @@ -103,6 +103,8 @@ pub struct SlotConfig { pub administrator: Option, pub description: Option, pub instances: Vec, + #[serde(default)] + pub timeout: Option, } // An user diff --git a/pkcs11/src/config/initialization.rs b/pkcs11/src/config/initialization.rs index 3d828218..17981f34 100644 --- a/pkcs11/src/config/initialization.rs +++ b/pkcs11/src/config/initialization.rs @@ -1,4 +1,7 @@ -use std::sync::{Arc, Mutex}; +use std::{ + sync::{Arc, Mutex}, + time::Duration, +}; use super::{ config_file::SlotConfig, @@ -117,11 +120,16 @@ fn slot_from_config(slot: &SlotConfig) -> Result { tls_conf.with_root_certificates(roots).with_no_client_auth() }; - let agent = ureq::AgentBuilder::new() + let mut builder = ureq::AgentBuilder::new() .tls_config(Arc::new(tls_conf)) .max_idle_connections(2) - .max_idle_connections_per_host(2) - .build(); + .max_idle_connections_per_host(2); + + if let Some(t) = slot.timeout { + builder = builder.timeout(Duration::from_secs(t)); + } + + let agent = builder.build(); let api_config = nethsm_sdk_rs::apis::configuration::Configuration { client: agent,