---
title: "Sign Artifacts with Cosign"
description: "Sign container images and files with cosign and Exoscale KMS: install the sigstore-kms-exoscalekms plugin, create a signing key and verify signatures."
url: https://community.exoscale.com/product/security/kms/recipes/cosign/
product: "Key Management Service (KMS)"
section: product
last_updated: 2026-11-18
---
> For AI agents: the documentation index is at https://community.exoscale.com/llms.txt. Every page is available as markdown at `<page URL>index.md` or with `Accept: text/markdown`.

# Sign Artifacts with Cosign

This guide is provided for informational purposes. Because it involves third party tooling we cannot guarantee things still work exactly as described here.

[Cosign](https://github.com/sigstore/cosign) from the [Sigstore](https://www.sigstore.dev/) project signs container images and files, so that consumers can check before use that a trusted party produced them. With the [sigstore-kms-exoscalekms](https://github.com/exoscale/sigstore-kms-exoscalekms) plugin, cosign signs with an asymmetric KMS key, and the private key never leaves Exoscale KMS.

## How It Works

Cosign hands signing to the plugin whenever a key reference starts with `exoscalekms://`. Only the digest of the artifact goes to the KMS, never the artifact itself.

Verification only needs the public key. Cosign verifies locally and never calls the KMS `verify` operation, so verifiers need no Exoscale credentials.

The plugin derives the signing algorithm from the `key-spec` of the KMS key, using an algorithm that cosign verifies by default:

| Key Spec | Signing Algorithm |
| ---------------------- | --------------------------- |
| `ECC_NIST_P256` | `ECDSA_SHA_256` |
| `ECC_NIST_P384` | `ECDSA_SHA_384` |
| `ECC_NIST_P521` | `ECDSA_SHA_512` |
| `RSA_3072`, `RSA_4096` | `RSASSA_PKCS1_V1_5_SHA_256` |

`ECC_EDWARDS25519`, `ML_DSA_65` and `ML_DSA_87` keys are not supported.

For the underlying KMS operations, see [Sign and Verify with Asymmetric KMS Keys](https://community.exoscale.com/product/security/kms/how-to/sign-verify/index.md).

## Prerequisites

- [Cosign](https://docs.sigstore.dev/cosign/system_config/installation/) v3.1.4 or later.
- The [Exoscale CLI](https://github.com/exoscale/cli) v1.104.0 or later, to create the signing key.
- An Exoscale API key, ideally restricted as described in [Restrict the API Key](#restrict-the-api-key).

## Install the Plugin

Install the plugin as described in the [plugin README](https://github.com/exoscale/sigstore-kms-exoscalekms#install). Cosign looks for a binary named `sigstore-kms-exoscalekms` on your `PATH`.

## Create a Signing Key

```bash
exo kms key create cosign-signing --usage sign-verify --key-spec ECC_NIST_P256 --zone <zone-name>
```

The command returns the key's UUID. The plugin references keys by UUID only, not by name. It does not create keys either, so `cosign generate-key-pair --kms` fails.

> [!NOTE]
> Asymmetric KMS keys cannot be rotated. To move to a new key pair, create a new KMS key and distribute its public key to your verifiers.

## Restrict the API Key

The plugin only calls the KMS `get-public-key` and `sign` operations. Create an [IAM role](https://community.exoscale.com/product/security/iam/quick-start/index.md) limited to these operations on the signing key, then an API key with this role. Replace `<key-uuid>` with the key's UUID:

```json
{
  "default-service-strategy": "deny",
  "services": {
    "kms": {
      "type": "rules",
      "rules": [
        {
          "expression": "operation in ['sign', 'get-public-key'] && resources.kms_key.id == '<key-uuid>'",
          "action": "allow"
        }
      ]
    }
  }
}
```

The plugin reads its configuration from environment variables only, not from the Exoscale CLI configuration file:

| Variable | Purpose |
| --------------------- | ------------------------------------------------ |
| `EXOSCALE_API_KEY` | API key |
| `EXOSCALE_API_SECRET` | API secret |
| `EXOSCALE_ZONE` | Zone of the key, when the key reference has none |

```bash
export EXOSCALE_API_KEY=<api-key>
export EXOSCALE_API_SECRET=<api-secret>
```

## Sign

The key reference tells cosign which KMS key to use:

| Key Reference | Zone |
| -------------------------------------- | ------------------------ |
| `exoscalekms://<zone-name>/<key-uuid>` | `<zone-name>` |
| `exoscalekms:///<key-uuid>` | Value of `EXOSCALE_ZONE` |

### Sign a File

```bash
cosign sign-blob --key exoscalekms://<zone-name>/<key-uuid> --bundle artifact.sigstore.json artifact.tar.gz
```

Cosign writes the signature to the bundle file `artifact.sigstore.json`. Distribute it next to the artifact.

### Sign a Container Image

Sign the image by digest rather than by tag:

```bash
cosign sign --key exoscalekms://<zone-name>/<key-uuid> <registry>/<image>@sha256:<digest>
```

Cosign pushes the signature to the registry next to the image, so you need write access to the registry.

> [!NOTE]
> With its default settings, cosign records every signature in the public [Rekor](https://docs.sigstore.dev/logging/overview/) transparency log. Pass `-y` to skip the confirmation prompt in non-interactive pipelines. Timestamp and transparency log settings are cosign options and work as with any other key, see the [cosign documentation](https://docs.sigstore.dev/cosign/signing/overview/).

## Verify

Export the public key and distribute it to your verifiers:

```bash
cosign public-key --key exoscalekms://<zone-name>/<key-uuid> > cosign.pub
```

Verify a file:

```bash
cosign verify-blob --key cosign.pub --bundle artifact.sigstore.json artifact.tar.gz
```

Verify a container image:

```bash
cosign verify --key cosign.pub <registry>/<image>@sha256:<digest>
```

Verifying with the public key file needs neither the plugin nor Exoscale credentials. Passing `--key exoscalekms://<zone-name>/<key-uuid>` also works: cosign fetches the public key from the KMS and verifies locally.

To admit only signed images to a Kubernetes cluster such as SKS, use the public key in an admission policy, as shown in [Sign Container Images With Cosign](https://www.exoscale.com/blog/sign-container-images-cosign/).

