Skip to content

varlink credentials API for ImportCredential= (Potential SPIFFE Workload Identity integration point) #40469

Open

Description

@arianvp

Component

No response

Is your feature request related to a problem? Please describe

Today we have a AF_UNIX support for LoadCredential= which implements a simple protocol where a single credential can be sent. The unit for which the credential is meant, and the name of the credential is passed to the listener through the peername.

However, this means it's not possible communicate a credential doesn't exist (#27373) and neither is it possible to communicate a set of credentials.

Describe the solution you'd like

Extend (or define a new varlink namespace for) the io.system.Credentials interface with a function

interface io.system.Credentials

# might return with continues: true if the service supports continuously pushing newly refreshed credentials
method ImportCredential(glob: string) -> (credentials: [](name: string, blob: string))

Have systemd look for varlink sockets and connect to them in /run/credentials/@varlink (name suggestions welcome) and query all the sockets with the glob passed to ImportCredential=. The listener can then reply with all the credentials available.

For making sure we return the credentials for the right systemd unit we keep the getpeername() trick of the original AF_UNIX interface as well.

Bonus features:

All the existing credential source search logic that ImportCredential= currently implements, we could perhaps move to the /run/systemd/io.systemd.Credentials socket that already exists today ?

We could also support peer authentication so that services that support it can just query the varlink socket for directly; instead of relying on systemd to mount the credentials for them. This is especially neat for user services and also makes it possible to load credentials without them ever being a file.

We could have the listener return the credential with a continues: true field. In this case systemd keeps the connection open and the varlink listener can push new credentials to the service. We could have that in turn trigger a service reload a la: #40093 This is useful as many secret engines (like e.g. openbao) watching for changes of secrets and would allow us to push those new credentials to the service as they expire. This would also make for a nice integration point for things like LetsEncrypt clients that want to push newly renewed certs to services instead of relying on systemd timers to renew. This is especially important as LetsEncrypt now supports dynamically queried renewal windows which means simple systemd timers might not suffice https://letsencrypt.org/2024/04/25/guide-to-integrating-ari-into-existing-acme-clients

This would also allow us to implement something like the SPIFFE Workload API as systemd credentials. SPIFFE Workload API is a GRPC interface to stream sets of continously renewed X509 credentials to a service. This idea was discussed at the Image Based Linux Summit. With these suggestions of streaming newer versions of credentials, we could map the SPIFFE API to Varlink credentials quite easily:

e.g. a spiffe workload API request / response could look like the following.

[Service]
Type=notify-reload
ExecStart=/usr/bin/nginx
ImportCredentials=io.spiffe.workload.x509.*

Systemd sends a request to /run/credentials/@varlink/spiffe to which my spire server is listening to.

{
  "method": "io.systemd.Credentials.ImportCredential",
  "parameters": {
    "glob": "io.spiffe.workload.x509.*"
  }
}

credential server now checks getpeername() to find the associated workload identities (or getpeercreds() if we allow the idea of services directly talking to the varlink API)

It finds two workload identities and responds with them. It also passes continues: true to signify new version of the credential can be pushed later.

{
  "parameters": {
    "credentials": [
      {
        "name": "io.spiffe.workload.x509.crl",
        "blob": "....."
      },
      {
        "name": "io.spiffe.workload.x509.svids.0.id",
        "blob": "spiffe://mydomain/workload/nginx/vhosts/arianvp.me",
      },
      {
        "name": "io.spiffe.workload.x509.svids.0.crt",
        "blob": "... the x509 cert",
      },
      {
        "name": "io.spiffe.workload.x509.svids.0.key",
        "blob": "... the private key",
      },

      /* a second workload identity associated with the caller */
      {
        "name": "io.spiffe.workload.x509.svids.1.id",
        "blob": "spiffe://mydomain/workload/nginx/vhosts/systemd.io",
      },
      {
        "name": "io.spiffe.workload.x509.svids.1.crt",
        "blob": "... the x509 cert",
      },
      {
        "name": "io.spiffe.workload.x509.svids.1.key",
        "blob": "... the private key",
      }
    ]
  },
  /* SPIFFE workload provider will push new credentials when the x509 certs are about to expire */
  "continues": true,
}

Describe alternatives you've considered

No response

The systemd version you checked that didn't have the feature you are asking for

No response

Activity

  1. added
    RFE 🎁
    on Jan 25, 2026
  2. YHNdnzj commented on Jan 25, 2026

    @YHNdnzj
    Member

    I'm pretty sure this should not be injected into ImportCredential=. It has a well-defined semantics of propagating the system credentials into a unit. And this will probably need to be guarded with some prefix namespacing so that a varlink service cannot effectively hijack credentials by returning the ones it shouldn't own

  3. YHNdnzj commented on Jan 25, 2026

    @YHNdnzj
    Member

    All the existing credential source search logic that ImportCredential= currently implements, we could perhaps move to the /run/systemd/io.systemd.Credentials socket that already exists today ?

    This just involves additionally roundtrips, and the search logic reuses internal helpers so I don't see the point...

  4. 197g commented on Feb 26, 2026

    @197g

    Credentials are arbitrary bytes. Sure enough a few of them (ascii armored certs, keys) are UTF-8 but in general they are not. The current interfaces handles that nicely. Correct me if I'm wrong but I don't think varlink maps this without requiring some form of encoding—which would impair the ability to use those credentials for keyfile process (e.g. cryptsetup). Calling it blob in the protocol seems almost cynical. How is that supposed to work?

  5. arianvp commented on Feb 26, 2026

    @arianvp
    ContributorAuthor

    The name blob is not new terminology; that's how the existing varlink interface calls it. It's a base64-encoded string

    SD_VARLINK_FIELD_COMMENT("The encrypted credential in Base64 encoding. This corresponds of the 'blob' field returned by the 'Encrypt' method."),

  6. 197g commented on Feb 26, 2026

    @197g

    I see, it's already in the varlink from systemd-creds. Of course that had its prior transcoding flags. I can't see it working nearly as well for the uses of unit credentials to enforce the transcoding, others may be less pessimistic. That said if all you have is a hammer, visit your local hardware store and expand your tool collection 😉

  7. 197g commented on Feb 26, 2026

    @197g

    I think what confused me quite a bit is that the example is inconsistent with this interpretation though, the blob examples are raw text and not base64 encoded ("blob": "spiffe://mydomain/workload/nginx/vhosts/arianvp.me"). As in should it be unencoding the credentials during import or not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFE 🎁creds

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions