Sign
API for signing artifacts.
Example:
from pathlib import Path
from sigstore.sign import SigningContext
from sigstore.oidc import Issuer
issuer = Issuer.production()
identity = issuer.identity_token()
# The artifact to sign
artifact = Path("foo.txt").read_bytes()
signing_ctx = SigningContext.production()
with signing_ctx.signer(identity, cache=True) as signer:
result = signer.sign_artifact(artifact)
print(result)
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
79 80 81 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 |
|
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
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
|
sign_artifact(input_)
Sign an artifact, and return a Bundle
corresponding to the signed result.
The input can be one of two forms:
- A
bytes
buffer; - A
Hashed
object, 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
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 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
|
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
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
|
production()
classmethod
Return a SigningContext
instance configured against Sigstore's production-level services.
Source code in sigstore/sign.py
331 332 333 334 335 336 337 338 339 340 |
|
staging()
classmethod
Return a SignerContext
instance configured against Sigstore's staging-level services.
Source code in sigstore/sign.py
342 343 344 345 346 347 348 349 350 351 |
|
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
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
|