Sign
API for signing artifacts.
Example:
from pathlib import Path
from sigstore.models import ClientTrustConfig
from sigstore.oidc import Issuer
from sigstore.sign import SigningContext
artifact_path = Path("README.md")
# Construct OIDC Issuer and SigningContext for the
# Sigstore Public Good instance
trust_config = ClientTrustConfig.production()
issuer = Issuer(trust_config.signing_config.get_oidc_url())
context = SigningContext.from_trust_config(trust_config)
# Get an identity token from OIDC provider using interactive auth
token = issuer.identity_token()
# Sign artifact with the identity
with context.signer(token, cache = True) as signer:
bundle = signer.sign_artifact(artifact_path.read_bytes())
with Path("README.md.sigstore.json").open("w") as f:
f.write(bundle.to_json())
Signer(identity_token, signing_ctx, cache=True)
The primary API for signing operations.
Create a new Signer.
identity_token is the identity token used to request a signing certificate
from Fulcio.
signing_ctx is a SigningContext that keeps information about the signing
configuration.
cache determines whether the signing certificate and ephemeral private key
should be reused (until the certificate expires) to sign different artifacts.
Default is True.
Source code in sigstore/sign.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
sign_dsse(input_)
Sign the given in-toto statement as a DSSE envelope, and return a
Bundle containing the signed result.
This API is only for in-toto statements; to sign arbitrary artifacts,
use sign_artifact instead.
Source code in sigstore/sign.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
sign_artifact(input_)
Sign an artifact, and return a Bundle corresponding to the signed result.
The input can be one of two forms:
- A
bytesbuffer; - A
Hashedobject, containing a pre-hashed input (e.g., for inputs that are too large to buffer into memory).
Regardless of the input format, the signing operation will produce a
hashedrekord entry within the bundle. No other entry types
are supported by this API.
Source code in sigstore/sign.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
SigningContext(*, fulcio, rekor, trusted_root, tsa_clients=None)
Keep a context between signing operations.
Create a new SigningContext.
fulcio is a FulcioClient capable of connecting to a Fulcio instance
and returning signing certificates.
rekor is a RekorClient capable of connecting to a Rekor instance
and creating transparency log entries.
Source code in sigstore/sign.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
from_trust_config(trust_config)
classmethod
Create a SigningContext from the given ClientTrustConfig.
@api private
Source code in sigstore/sign.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
signer(identity_token, *, cache=True)
A context manager for signing operations.
identity_token is the identity token passed to the Signer instance
and used to request a signing certificate from Fulcio.
cache determines whether the signing certificate and ephemeral private key
generated by the Signer instance should be reused (until the certificate expires)
to sign different artifacts.
Default is True.
Source code in sigstore/sign.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | |