Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Sigstore Releases Python Client

Sigstore Releases Python Client

Sigstore has announced the 1.0 stable release of sigstore-python, a Python-based Sigstore-compatible client. The client provides a CLI as well as an importable Python API. It is able to sign and verify with any Sigstore-supported identity and has ambient identity detection for supported environments.

Sigstore provides a standard for signing, verifying, and protecting open-source software. It supports a process known as keyless signing where Sigstore generates ephemeral signing certificates without needing to maintain a private key. When generating a certificate, Sigstore encodes information from the OIDC token. This includes the path to the repository, the specific commit of the build, and a link to the file that contains the build instructions.

According to William Woodruff, the project had two main goals: usability and reference quality. As Woodruff explains, "sigstore-python should provide an extremely intuitive CLI and API, with 100 percent documentation coverage and practical examples for both." There are other Sigstore clients being developed, such as for Go, Ruby, Java, and Rust, but the team would like sigstore-python to be among the "most authoritative in terms of succinctly and correctly implementing the intricacies of Sigstore’s security model."

To achieve the usability goal, the client obfuscates away many of the complicated bits of cryptography and opts to present two main primitives: signing and verifying. For example, signing can be accomplished via the CLI using sigstore sign:

$ echo "hello, i'm signing this!" > hello.txt
$ sigstore sign hello.txt

On desktops, this will prompt an OAuth2 workflow to provide authentication. On supported CI platforms, the client will automatically select an OpenID Connect identity. Currently, GitHub Actions, Google Compute Engine (GCE), and Google Cloud Build (GCB) are supported. There are plans to add support for GitLab CI and CircleCI.

With the importable Python API, it is possible to accomplish the same tasks as the CLI but within Python. For example, the above signing example but using the Python API looks like this:

mport io

from sigstore.sign import Signer
from sigstore.oidc import Issuer

contents = io.BytesIO(b"hello, i'm signing this!")

# NOTE: identity_token() performs an interactive OAuth2 flow;
# see other members of `sigstore.oidc` for other credential
# mechanisms.
issuer = Issuer.production()
token = issuer.identity_token()

signer = Signer.production()
result = signer.sign(input_=contents, identity_token=token)

The GitHub Action can be enabled by adding sigstore/gh-action-sigstore-python to the desired workflow. Note that the workflow must have permission to request the OIDC token to authenticate with. This is done by setting id-token: write on the job or workflow:

    runs-on: ubuntu-latest
      id-token: write
      - uses: actions/checkout@v3
      - name: install
        run: python -m pip install .
      - uses: sigstore/gh-action-sigstore-python@v1.0.0
          inputs: file.txt

Woodruff notes that the project is committing to semantic versioning for both the Python API and the CLI. They indicate that breaking changes will not be made without a corresponding major version bump. In future releases, Woodruff indicates there will be further integration into PyPI and the client-side packaging toolchain. They also hope to stabilize their GitHub Action.

sigstore-python is open-source and available under the Apache 2.0 license. Additional details can be found in the API documentation or in the #python channel of the Sigstore Slack.

About the Author

Rate this Article