Support interactive customer transfers for enrolled devices
Rust development slice / linux (push) Failing after 8s
Rust development slice / linux (push) Failing after 8s
This commit is contained in:
@@ -0,0 +1,477 @@
|
||||
use crate::{auth::Principal, jobs::Error};
|
||||
use axum::{
|
||||
Extension, Json, Router,
|
||||
extract::{Path, Query, State},
|
||||
http::{HeaderMap, StatusCode},
|
||||
response::{IntoResponse, Response},
|
||||
routing::{get, post},
|
||||
};
|
||||
use chrono::{DateTime, Utc};
|
||||
use rmm_domain::{customer_transfer as wire, jobs::hash};
|
||||
use serde::Deserialize;
|
||||
use serde_json::{Value, json};
|
||||
use sqlx::{Postgres, Row, Transaction};
|
||||
use uuid::Uuid;
|
||||
|
||||
const NOT_FOUND: Error = Error(StatusCode::NOT_FOUND, "NOT_FOUND");
|
||||
|
||||
fn private_json(body: Value) -> Response {
|
||||
([("cache-control", "private, no-store")], Json(body)).into_response()
|
||||
}
|
||||
|
||||
pub(crate) fn gateway_routes(router: Router<crate::State>) -> Router<crate::State> {
|
||||
router
|
||||
.route("/agent/v1/customer-transfer", get(device_offer))
|
||||
.route(
|
||||
"/agent/v1/customer-transfer/{transfer}/certificate",
|
||||
post(device_certificate),
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn routes(router: Router<crate::State>) -> Router<crate::State> {
|
||||
router
|
||||
.route(
|
||||
"/api/v1/tenants/{tenant}/devices/{asset}/customer-transfer",
|
||||
get(status).post(begin),
|
||||
)
|
||||
.route(
|
||||
"/api/v1/tenants/{tenant}/devices/{asset}/customer-transfer/{transfer}/complete",
|
||||
post(complete),
|
||||
)
|
||||
.route(
|
||||
"/api/v1/tenants/{tenant}/devices/{asset}/customer-transfer/{transfer}/cancel",
|
||||
post(cancel),
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Pairing {
|
||||
agent_id: Uuid,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Destination {
|
||||
target_tenant_id: Uuid,
|
||||
}
|
||||
|
||||
struct Transfer {
|
||||
transfer_id: Uuid,
|
||||
target_tenant_id: Uuid,
|
||||
target_asset_id: Option<Uuid>,
|
||||
target_agent_id: Option<Uuid>,
|
||||
csr_sha256: Option<String>,
|
||||
requested_by: String,
|
||||
completed_at: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
async fn source<'a>(
|
||||
s: &'a crate::State,
|
||||
headers: &HeaderMap,
|
||||
tenant: Uuid,
|
||||
write: bool,
|
||||
) -> Result<(Principal, Transaction<'a, Postgres>), Error> {
|
||||
let p = crate::jobs::principal(s, headers, write).await?;
|
||||
crate::jobs::scope(&p, tenant, write)?;
|
||||
if p.session_hash.is_none() {
|
||||
return Err(Error(StatusCode::FORBIDDEN, "INTERACTIVE_AUTH_REQUIRED"));
|
||||
}
|
||||
let mut tx = rmm_persistence::tenant_tx(&s.pool, tenant).await?;
|
||||
crate::permissions::require_principal(&mut tx, &p, "inventory:read").await?;
|
||||
crate::permissions::require_principal(&mut tx, &p, "devices:revoke").await?;
|
||||
Ok((p, tx))
|
||||
}
|
||||
|
||||
async fn select_tenant(tx: &mut Transaction<'_, Postgres>, tenant: Uuid) -> Result<(), Error> {
|
||||
sqlx::query("SELECT set_config('app.tenant_id',$1,true)")
|
||||
.bind(tenant.to_string())
|
||||
.execute(&mut **tx)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn destination(
|
||||
tx: &mut Transaction<'_, Postgres>,
|
||||
p: &Principal,
|
||||
target: Uuid,
|
||||
) -> Result<(), Error> {
|
||||
if target == p.tenant || !p.tenants.contains(&target) {
|
||||
return Err(NOT_FOUND);
|
||||
}
|
||||
select_tenant(tx, target).await?;
|
||||
crate::permissions::require_principal(tx, p, "inventory:read").await?;
|
||||
crate::permissions::require_principal(tx, p, "devices:enroll").await
|
||||
}
|
||||
|
||||
async fn transfer(
|
||||
tx: &mut Transaction<'_, Postgres>,
|
||||
agent: Uuid,
|
||||
) -> Result<Option<Transfer>, Error> {
|
||||
let row = sqlx::query(
|
||||
"SELECT transfer_id,target_tenant_id,target_asset_id,target_agent_id,csr_sha256,requested_by,completed_at
|
||||
FROM device_customer_transfers WHERE source_agent_id=$1 AND cancelled_at IS NULL",
|
||||
)
|
||||
.bind(agent)
|
||||
.fetch_optional(&mut **tx)
|
||||
.await?;
|
||||
Ok(row.map(|row| Transfer {
|
||||
transfer_id: row.get("transfer_id"),
|
||||
target_tenant_id: row.get("target_tenant_id"),
|
||||
target_asset_id: row.get("target_asset_id"),
|
||||
target_agent_id: row.get("target_agent_id"),
|
||||
csr_sha256: row.get("csr_sha256"),
|
||||
requested_by: row.get("requested_by"),
|
||||
completed_at: row.get("completed_at"),
|
||||
}))
|
||||
}
|
||||
|
||||
async fn target_hostname(
|
||||
tx: &mut Transaction<'_, Postgres>,
|
||||
t: &Transfer,
|
||||
) -> Result<Option<String>, Error> {
|
||||
let (Some(asset), Some(agent)) = (t.target_asset_id, t.target_agent_id) else {
|
||||
return Ok(None);
|
||||
};
|
||||
Ok(sqlx::query_scalar(
|
||||
"SELECT o.data->>'hostname' FROM agent_installations a
|
||||
JOIN LATERAL (
|
||||
SELECT data FROM observations WHERE tenant_id=a.tenant_id AND agent_id=a.agent_id AND source_id IN ('linux.base','windows.base')
|
||||
ORDER BY observed_at DESC, received_at DESC, sequence DESC LIMIT 1
|
||||
) o ON true
|
||||
WHERE a.asset_id=$1 AND a.agent_id=$2 AND a.revoked_at IS NULL
|
||||
AND a.last_authenticated_at IS NOT NULL AND length(o.data->>'hostname')>0",
|
||||
)
|
||||
.bind(asset).bind(agent)
|
||||
.fetch_optional(&mut **tx).await?)
|
||||
}
|
||||
|
||||
async fn status(
|
||||
State(s): State<crate::State>,
|
||||
headers: HeaderMap,
|
||||
Path((tenant, asset)): Path<(Uuid, Uuid)>,
|
||||
Query(pair): Query<Pairing>,
|
||||
) -> Result<Response, Error> {
|
||||
let (p, mut tx) = source(&s, &headers, tenant, false).await?;
|
||||
verify_pairing(&mut tx, asset, pair.agent_id).await?;
|
||||
let Some(t) = transfer(&mut tx, pair.agent_id).await? else {
|
||||
return Ok(private_json(json!({"transfer":null})));
|
||||
};
|
||||
destination(&mut tx, &p, t.target_tenant_id).await?;
|
||||
let hostname = target_hostname(&mut tx, &t).await?;
|
||||
let state = if t.completed_at.is_some() {
|
||||
"completed"
|
||||
} else if hostname.is_some() {
|
||||
"ready"
|
||||
} else if t.target_agent_id.is_some() {
|
||||
"enrolled"
|
||||
} else {
|
||||
"pending"
|
||||
};
|
||||
tx.commit().await?;
|
||||
Ok(private_json(json!({"transfer":{
|
||||
"transfer_id":t.transfer_id, "state":state,
|
||||
"target_tenant_id":t.target_tenant_id, "target_asset_id":t.target_asset_id,
|
||||
"target_agent_id":t.target_agent_id, "target_hostname":hostname
|
||||
}})))
|
||||
}
|
||||
|
||||
async fn lock_source(
|
||||
tx: &mut Transaction<'_, Postgres>,
|
||||
tenant: Uuid,
|
||||
asset: Uuid,
|
||||
agent: Uuid,
|
||||
) -> Result<bool, Error> {
|
||||
crate::agent_service::control_lock(tx, tenant, agent).await?;
|
||||
sqlx::query_scalar(
|
||||
"SELECT i.revoked_at IS NULL AND i.last_authenticated_at IS NOT NULL AND a.archived_at IS NULL
|
||||
FROM agent_installations i JOIN assets a USING (tenant_id,asset_id)
|
||||
WHERE i.asset_id=$1 AND i.agent_id=$2 FOR UPDATE OF i",
|
||||
)
|
||||
.bind(asset)
|
||||
.bind(agent)
|
||||
.fetch_optional(&mut **tx)
|
||||
.await?
|
||||
.ok_or(NOT_FOUND)
|
||||
}
|
||||
|
||||
async fn ensure_idle(tx: &mut Transaction<'_, Postgres>, agent: Uuid) -> Result<(), Error> {
|
||||
let busy: bool = sqlx::query_scalar(
|
||||
"SELECT EXISTS(SELECT FROM jobs WHERE agent_id=$1
|
||||
AND state NOT IN ('succeeded','failed','cancelled','expired','closed_unknown'))
|
||||
OR EXISTS(SELECT FROM approval_requests r JOIN operation_plans p USING(tenant_id,plan_id)
|
||||
WHERE r.approval_state='pending_approval' AND p.expires_at>now()
|
||||
AND convert_from(p.payload,'UTF8')::jsonb->'jobs'
|
||||
@> jsonb_build_array(jsonb_build_object('payload',jsonb_build_object('agent_id',$1::uuid))))",
|
||||
)
|
||||
.bind(agent)
|
||||
.fetch_one(&mut **tx)
|
||||
.await?;
|
||||
if busy {
|
||||
return Err(Error(StatusCode::CONFLICT, "DEVICE_HAS_OPEN_WORK"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn audit(
|
||||
tx: &mut Transaction<'_, Postgres>,
|
||||
p: &Principal,
|
||||
event: &str,
|
||||
details: Value,
|
||||
) -> Result<(), Error> {
|
||||
sqlx::query("INSERT INTO audit_events VALUES($1,$2,$3,$4,$5,now())")
|
||||
.bind(p.tenant).bind(Uuid::new_v4()).bind(&p.name).bind(event)
|
||||
.bind(json!({"decision":details,"session_hash":p.session_hash,"approval_origin":p.approval_origin(),"testsimulation":p.testsimulation}))
|
||||
.execute(&mut **tx).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn begin(
|
||||
State(s): State<crate::State>,
|
||||
headers: HeaderMap,
|
||||
Path((tenant, asset)): Path<(Uuid, Uuid)>,
|
||||
Query(pair): Query<Pairing>,
|
||||
Json(input): Json<Destination>,
|
||||
) -> Result<Response, Error> {
|
||||
let (p, mut tx) = source(&s, &headers, tenant, true).await?;
|
||||
destination(&mut tx, &p, input.target_tenant_id).await?;
|
||||
crate::agent_updates::ensure_customer_starters(&mut tx, input.target_tenant_id).await?;
|
||||
select_tenant(&mut tx, tenant).await?;
|
||||
if !lock_source(&mut tx, tenant, asset, pair.agent_id).await? {
|
||||
return Err(Error(StatusCode::CONFLICT, "TRANSFER_SOURCE_INACTIVE"));
|
||||
}
|
||||
ensure_idle(&mut tx, pair.agent_id).await?;
|
||||
let supported: bool =
|
||||
sqlx::query_scalar("SELECT capabilities ? $2 FROM agent_installations WHERE agent_id=$1")
|
||||
.bind(pair.agent_id)
|
||||
.bind(wire::CAPABILITY)
|
||||
.fetch_one(&mut *tx)
|
||||
.await?;
|
||||
if !supported {
|
||||
return Err(Error(
|
||||
StatusCode::CONFLICT,
|
||||
"TRANSFER_AGENT_UPDATE_REQUIRED",
|
||||
));
|
||||
}
|
||||
if transfer(&mut tx, pair.agent_id).await?.is_some() {
|
||||
return Err(Error(StatusCode::CONFLICT, "TRANSFER_ALREADY_PENDING"));
|
||||
}
|
||||
let id = Uuid::new_v4();
|
||||
sqlx::query(
|
||||
"INSERT INTO device_customer_transfers(transfer_id,source_tenant_id,source_asset_id,source_agent_id,target_tenant_id,requested_by)
|
||||
VALUES($1,$2,$3,$4,$5,$6)",
|
||||
).bind(id).bind(tenant).bind(asset).bind(pair.agent_id).bind(input.target_tenant_id).bind(&p.name)
|
||||
.execute(&mut *tx).await?;
|
||||
audit(&mut tx, &p, "device_customer_transfer_prepared", json!({
|
||||
"transfer_id":id,"asset_id":asset,"agent_id":pair.agent_id,"target_tenant_id":input.target_tenant_id
|
||||
})).await?;
|
||||
tx.commit().await?;
|
||||
Ok(private_json(json!({"transfer_id":id,"state":"pending"})))
|
||||
}
|
||||
|
||||
async fn verify_pairing(
|
||||
tx: &mut Transaction<'_, Postgres>,
|
||||
asset: Uuid,
|
||||
agent: Uuid,
|
||||
) -> Result<(), Error> {
|
||||
sqlx::query_scalar::<_, Uuid>(
|
||||
"SELECT agent_id FROM agent_installations WHERE asset_id=$1 AND agent_id=$2",
|
||||
)
|
||||
.bind(asset)
|
||||
.bind(agent)
|
||||
.fetch_optional(&mut **tx)
|
||||
.await?
|
||||
.ok_or(NOT_FOUND)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn cancel(
|
||||
State(s): State<crate::State>,
|
||||
headers: HeaderMap,
|
||||
Path((tenant, asset, id)): Path<(Uuid, Uuid, Uuid)>,
|
||||
Query(pair): Query<Pairing>,
|
||||
) -> Result<StatusCode, Error> {
|
||||
let (p, mut tx) = source(&s, &headers, tenant, true).await?;
|
||||
lock_source(&mut tx, tenant, asset, pair.agent_id).await?;
|
||||
let changed = sqlx::query(
|
||||
"UPDATE device_customer_transfers SET cancelled_at=now()
|
||||
WHERE transfer_id=$1 AND source_agent_id=$2 AND target_agent_id IS NULL AND cancelled_at IS NULL",
|
||||
).bind(id).bind(pair.agent_id).execute(&mut *tx).await?.rows_affected();
|
||||
if changed == 0 {
|
||||
return Err(Error(StatusCode::CONFLICT, "TRANSFER_ALREADY_STARTED"));
|
||||
}
|
||||
audit(
|
||||
&mut tx,
|
||||
&p,
|
||||
"device_customer_transfer_cancelled",
|
||||
json!({
|
||||
"transfer_id":id,"asset_id":asset,"agent_id":pair.agent_id
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
tx.commit().await?;
|
||||
Ok(StatusCode::NO_CONTENT)
|
||||
}
|
||||
|
||||
async fn complete(
|
||||
State(s): State<crate::State>,
|
||||
headers: HeaderMap,
|
||||
Path((tenant, asset, id)): Path<(Uuid, Uuid, Uuid)>,
|
||||
Query(pair): Query<Pairing>,
|
||||
) -> Result<Response, Error> {
|
||||
let (p, mut tx) = source(&s, &headers, tenant, true).await?;
|
||||
lock_source(&mut tx, tenant, asset, pair.agent_id).await?;
|
||||
let t = transfer(&mut tx, pair.agent_id)
|
||||
.await?
|
||||
.filter(|t| t.transfer_id == id)
|
||||
.ok_or(NOT_FOUND)?;
|
||||
destination(&mut tx, &p, t.target_tenant_id).await?;
|
||||
if t.completed_at.is_some() {
|
||||
return Ok(private_json(json!({"state":"completed"})));
|
||||
}
|
||||
if target_hostname(&mut tx, &t).await?.is_none() {
|
||||
return Err(Error(StatusCode::CONFLICT, "TRANSFER_TARGET_NOT_READY"));
|
||||
}
|
||||
select_tenant(&mut tx, tenant).await?;
|
||||
ensure_idle(&mut tx, pair.agent_id).await?;
|
||||
sqlx::query(
|
||||
"UPDATE agent_installations SET revoked_at=now(), connection_generation=connection_generation+1,
|
||||
previous_certificate_sha256=NULL,previous_certificate_until=NULL
|
||||
WHERE asset_id=$1 AND agent_id=$2 AND revoked_at IS NULL",
|
||||
)
|
||||
.bind(asset).bind(pair.agent_id).execute(&mut *tx).await?;
|
||||
sqlx::query("UPDATE device_customer_transfers SET completed_at=now() WHERE transfer_id=$1")
|
||||
.bind(id)
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
audit(&mut tx, &p, "device_customer_transfer_completed", json!({
|
||||
"transfer_id":id,"asset_id":asset,"agent_id":pair.agent_id,"target_tenant_id":t.target_tenant_id,
|
||||
"target_asset_id":t.target_asset_id,"target_agent_id":t.target_agent_id
|
||||
})).await?;
|
||||
tx.commit().await?;
|
||||
Ok(private_json(json!({"state":"completed"})))
|
||||
}
|
||||
|
||||
async fn device_offer(
|
||||
State(s): State<crate::State>,
|
||||
Extension(peer): Extension<crate::Peer>,
|
||||
headers: HeaderMap,
|
||||
) -> Result<Response, Error> {
|
||||
let (tenant, agent) = crate::agent_updates::device(&s, peer, &headers).await?;
|
||||
let mut tx = rmm_persistence::tenant_tx(&s.pool, tenant).await?;
|
||||
let offer = transfer(&mut tx, agent)
|
||||
.await?
|
||||
.filter(|t| t.completed_at.is_none())
|
||||
.map(|t| offer(tenant, agent, &t));
|
||||
tx.commit().await?;
|
||||
Ok(private_json(json!({"offer":offer})))
|
||||
}
|
||||
|
||||
fn offer(tenant: Uuid, agent: Uuid, t: &Transfer) -> wire::Offer {
|
||||
wire::Offer {
|
||||
transfer_id: t.transfer_id,
|
||||
source_tenant_id: tenant,
|
||||
source_agent_id: agent,
|
||||
target_tenant_id: t.target_tenant_id,
|
||||
}
|
||||
}
|
||||
|
||||
async fn device_certificate(
|
||||
State(s): State<crate::State>,
|
||||
Extension(peer): Extension<crate::Peer>,
|
||||
headers: HeaderMap,
|
||||
Path(id): Path<Uuid>,
|
||||
Json(input): Json<wire::CertificateRequest>,
|
||||
) -> Result<Response, Error> {
|
||||
let (tenant, agent) = crate::agent_updates::device(&s, peer, &headers).await?;
|
||||
let invalid = || Error(StatusCode::BAD_REQUEST, "INVALID_CSR");
|
||||
if input.csr_pem.len() > 8192 {
|
||||
return Err(invalid());
|
||||
}
|
||||
let csr = openssl::x509::X509Req::from_pem(input.csr_pem.as_bytes()).map_err(|_| invalid())?;
|
||||
let public = csr.public_key().map_err(|_| invalid())?;
|
||||
if !csr.verify(&public).map_err(|_| invalid())? {
|
||||
return Err(invalid());
|
||||
}
|
||||
let digest = hash(&public.public_key_to_der().map_err(|_| invalid())?);
|
||||
let mut tx = rmm_persistence::tenant_tx(&s.pool, tenant).await?;
|
||||
crate::agent_service::control_lock(&mut tx, tenant, agent).await?;
|
||||
let (asset, generation): (Uuid, i64) = sqlx::query_as(
|
||||
"SELECT asset_id,connection_generation FROM agent_installations
|
||||
WHERE agent_id=$1 AND revoked_at IS NULL FOR UPDATE",
|
||||
)
|
||||
.bind(agent)
|
||||
.fetch_optional(&mut *tx)
|
||||
.await?
|
||||
.ok_or(NOT_FOUND)?;
|
||||
let t = transfer(&mut tx, agent)
|
||||
.await?
|
||||
.filter(|t| t.transfer_id == id && t.completed_at.is_none())
|
||||
.ok_or(NOT_FOUND)?;
|
||||
ensure_idle(&mut tx, agent).await?;
|
||||
if t.target_agent_id.is_none() {
|
||||
crate::permissions::require(&mut tx, &t.requested_by, "inventory:read").await?;
|
||||
crate::permissions::require(&mut tx, &t.requested_by, "devices:revoke").await?;
|
||||
}
|
||||
select_tenant(&mut tx, t.target_tenant_id).await?;
|
||||
let (new_asset, new_agent, certificate_pem) = if let (Some(target_asset), Some(target_agent)) =
|
||||
(t.target_asset_id, t.target_agent_id)
|
||||
{
|
||||
if t.csr_sha256.as_deref() != Some(&digest) {
|
||||
return Err(Error(StatusCode::CONFLICT, "TRANSFER_KEY_MISMATCH"));
|
||||
}
|
||||
let pem: String = sqlx::query_scalar(
|
||||
"SELECT certificate_pem FROM agent_installations WHERE asset_id=$1 AND agent_id=$2 AND revoked_at IS NULL",
|
||||
).bind(target_asset).bind(target_agent).fetch_optional(&mut *tx).await?.ok_or(NOT_FOUND)?;
|
||||
sqlx::query(
|
||||
"UPDATE agent_installations SET connection_generation=GREATEST(connection_generation,$2)
|
||||
WHERE agent_id=$1 AND last_authenticated_at IS NULL",
|
||||
).bind(target_agent).bind(generation).execute(&mut *tx).await?;
|
||||
(target_asset, target_agent, pem)
|
||||
} else {
|
||||
crate::permissions::require(&mut tx, &t.requested_by, "inventory:read").await?;
|
||||
crate::permissions::require(&mut tx, &t.requested_by, "devices:enroll").await?;
|
||||
let new_asset = Uuid::new_v4();
|
||||
let new_agent = Uuid::new_v4();
|
||||
let certificate =
|
||||
crate::tls::issue(&s, &input.csr_pem, new_agent).map_err(|_| invalid())?;
|
||||
let pem = String::from_utf8(certificate.to_pem().map_err(anyhow::Error::from)?)
|
||||
.map_err(anyhow::Error::from)?;
|
||||
sqlx::query("INSERT INTO assets(tenant_id,asset_id) VALUES($1,$2)")
|
||||
.bind(t.target_tenant_id)
|
||||
.bind(new_asset)
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
sqlx::query(
|
||||
"INSERT INTO agent_installations(tenant_id,asset_id,agent_id,certificate_sha256,certificate_pem,connection_generation)
|
||||
VALUES($1,$2,$3,$4,$5,$6)",
|
||||
).bind(t.target_tenant_id).bind(new_asset).bind(new_agent)
|
||||
.bind(hash(&certificate.to_der().map_err(anyhow::Error::from)?)).bind(&pem).bind(generation)
|
||||
.execute(&mut *tx).await?;
|
||||
select_tenant(&mut tx, tenant).await?;
|
||||
sqlx::query(
|
||||
"UPDATE device_customer_transfers SET target_asset_id=$2,target_agent_id=$3,csr_sha256=$4
|
||||
WHERE transfer_id=$1 AND source_asset_id=$5",
|
||||
).bind(id).bind(new_asset).bind(new_agent).bind(digest).bind(asset).execute(&mut *tx).await?;
|
||||
(new_asset, new_agent, pem)
|
||||
};
|
||||
let binding = wire::Binding {
|
||||
offer: offer(tenant, agent, &t),
|
||||
asset_id: new_asset,
|
||||
agent_id: new_agent,
|
||||
certificate_sha256: hash(certificate_pem.as_bytes()),
|
||||
};
|
||||
let signature_hex = hex::encode(s.job_signer.sign(&binding.signing_bytes()?)?);
|
||||
tx.commit().await?;
|
||||
Ok((
|
||||
[("cache-control", "private, no-store")],
|
||||
Json(wire::CertificateResponse {
|
||||
certificate_pem,
|
||||
receipt: wire::Receipt {
|
||||
binding,
|
||||
signature_hex,
|
||||
},
|
||||
}),
|
||||
)
|
||||
.into_response())
|
||||
}
|
||||
Reference in New Issue
Block a user