Skip to content

Commit f12f3d2

Browse files
authored
Release/1.1.0 (#81)
* doc: add updated google key-pairs create command (#76) * Update to new auth0 tokens (#77) * Feat/secret data (#78) * CLI create test * update kms on 5.6.0 release
1 parent 91efd9a commit f12f3d2

File tree

17 files changed

+182
-46
lines changed

17 files changed

+182
-46
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [1.1.0] - 2025-07-23
6+
7+
### 🚀 Features
8+
9+
- Handle Secret Data
10+
511
## [1.0.0] - 2025-07-08
612

713
### 🚀 Features

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ exclude = ["kms"]
1414
resolver = "2"
1515

1616
[workspace.package]
17-
version = "1.0.0"
17+
version = "1.1.0"
1818
edition = "2024"
1919
rust-version = "1.85.0"
2020
authors = [
@@ -53,7 +53,7 @@ cosmian_crypto_core = { version = "10.1", default-features = false, features = [
5353
"ser",
5454
] }
5555
cosmian_findex_cli = { path = "findex-server/crate/cli" }
56-
cosmian_kms_cli = { path = "kms/crate/cli", version = "5.3.3" }
56+
cosmian_kms_cli = { path = "kms/crate/cli", version = "5.6.0" }
5757
cosmian_http_client = "0.2"
5858
cosmian_logger = "0.2"
5959
der = { version = "0.7", default-features = false }

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM rust:1.79.0-buster AS builder
22

3-
LABEL version="1.0.0"
3+
LABEL version="1.1.0"
44
LABEL name="Cosmian PKCS11 library container"
55

66
ENV OPENSSL_DIR=/usr/local/openssl

ca.ext

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[ v3_ca ]
2+
subjectKeyIdentifier=hash
3+
basicConstraints=critical,CA:TRUE

crate/cli/src/tests/kms/certificates/get_attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async fn test_get_attributes_p12() -> CosmianResult<()> {
5151
pkcs12_attributes
5252
.get(&Tag::KeyFormatType.to_string())
5353
.unwrap(),
54-
&serde_json::json!("PKCS1")
54+
&serde_json::json!("PKCS8")
5555
);
5656
let intermediate_certificate_id: String = serde_json::from_value(
5757
pkcs12_attributes

crate/cli/src/tests/kms/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mod hash;
1010
mod hsm;
1111
mod mac;
1212
mod rsa;
13+
mod secret_data;
1314
mod shared;
1415
mod symmetric;
1516
pub(crate) mod utils;
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
use std::{collections::HashSet, process::Command};
2+
3+
use assert_cmd::prelude::*;
4+
use cosmian_kms_cli::reexport::test_kms_server::start_default_test_kms_server;
5+
6+
use crate::{
7+
config::COSMIAN_CLI_CONF_ENV,
8+
error::{CosmianError, result::CosmianResult},
9+
tests::{
10+
PROG_NAME,
11+
kms::{
12+
KMS_SUBCOMMAND,
13+
utils::{extract_uids::extract_unique_identifier, recover_cmd_logs},
14+
},
15+
save_kms_cli_config,
16+
},
17+
};
18+
19+
#[derive(Default)]
20+
pub(crate) struct SecretDataOptions {
21+
pub(crate) tags: HashSet<String>,
22+
pub(crate) sensitive: bool,
23+
pub(crate) key_id: Option<String>,
24+
}
25+
26+
pub(crate) fn create_secret_data(
27+
cli_conf_path: &str,
28+
options: &SecretDataOptions,
29+
) -> CosmianResult<String> {
30+
let mut cmd = Command::cargo_bin(PROG_NAME)?;
31+
cmd.env(COSMIAN_CLI_CONF_ENV, cli_conf_path);
32+
33+
let mut args = vec!["secret-data", "create"];
34+
35+
// add tags
36+
for tag in &options.tags {
37+
args.push("--tag");
38+
args.push(tag);
39+
}
40+
if options.sensitive {
41+
args.push("--sensitive");
42+
}
43+
if let Some(key_id) = options.key_id.as_ref() {
44+
args.push(key_id);
45+
}
46+
cmd.arg(KMS_SUBCOMMAND).args(args);
47+
48+
let output = recover_cmd_logs(&mut cmd);
49+
if output.status.success() {
50+
let secret_data_output = std::str::from_utf8(&output.stdout)?;
51+
assert!(secret_data_output.contains("The secret data was successfully generated."));
52+
let secret_data_id = extract_unique_identifier(secret_data_output)
53+
.ok_or_else(|| CosmianError::Default("failed extracting the private key".to_owned()))?
54+
.to_owned();
55+
return Ok(secret_data_id)
56+
}
57+
58+
Err(CosmianError::Default(
59+
std::str::from_utf8(&output.stderr)?.to_owned(),
60+
))
61+
}
62+
63+
#[tokio::test]
64+
pub(crate) async fn test_secret_data() -> CosmianResult<()> {
65+
// from specs
66+
let ctx = start_default_test_kms_server().await;
67+
let (owner_client_conf_path, _) = save_kms_cli_config(ctx);
68+
create_secret_data(
69+
&owner_client_conf_path,
70+
&SecretDataOptions {
71+
tags: HashSet::from_iter(vec!["tag1".to_owned(), "tag2".to_owned()]),
72+
..Default::default()
73+
},
74+
)?;
75+
76+
let created_id = create_secret_data(
77+
&owner_client_conf_path,
78+
&SecretDataOptions {
79+
key_id: Some("secret_id".to_owned()),
80+
tags: HashSet::from_iter(vec!["tag1".to_owned(), "tag2".to_owned()]),
81+
..Default::default()
82+
},
83+
)?;
84+
assert_eq!(created_id, "secret_id".to_owned());
85+
Ok(())
86+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub(crate) mod create_secret;

crate/pkcs11/provider/src/kms_object.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ async fn locate_objects(kms_rest_client: &KmsClient, tags: &[String]) -> Pkcs11R
155155
..Default::default()
156156
};
157157
let response = kms_rest_client.locate(locate).await?;
158-
debug!("Locate response: ids: {:?}", response.unique_identifiers);
158+
debug!("Locate response: ids: {:?}", response.unique_identifier);
159159
let uniques_identifiers = response
160-
.unique_identifiers
160+
.unique_identifier
161161
.unwrap_or_default()
162162
.iter()
163163
.map(std::string::ToString::to_string)

0 commit comments

Comments
 (0)