-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Sigstore signing and verification (v2) #46
Open
mayaCostantini
wants to merge
15
commits into
ansible:main
Choose a base branch
from
mayaCostantini:sigstorev2-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7cb1100
Add support for Sigstore signing and verification (v2)
mayaCostantini e906bdb
Remove Sigstore signer subclass
mayaCostantini 12fba3e
Add sigstore test fixtures
mayaCostantini eba0a15
Adapt test_cli to sigstore v2
mayaCostantini 9062d65
Fix verification materials unpacking
mayaCostantini 65c8aaa
Add __all__ in signing submodule
mayaCostantini 1ee46cf
Remove arguments from _collect_verification_state() for sigstore sign…
mayaCostantini 7c7b104
Update sigstore-python version to stable v2.0.0
mayaCostantini 860a4f8
Backport fix from sigstore-python CLI https://github.com/sigstore/sig…
mayaCostantini 38c7525
Update public keys fetching logic
mayaCostantini 1e33cfa
Remove sigstore bundles from .gitignore for tests
mayaCostantini f4206e7
Update documentation for sigstore signing with project subcommand
mayaCostantini 6e5631c
Do not ignore .ansible-sign files as test fixtures
mayaCostantini bc46f52
Bump sigstore dependency to 2.1.2
mayaCostantini e575be6
Fix sigstore-related tests
mayaCostantini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,3 +52,7 @@ MANIFEST | |
.venv*/ | ||
.conda*/ | ||
.python-version | ||
|
||
# ansible-sign files and directories | ||
/.ansible-sign/* | ||
/MANIFEST.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,6 +230,110 @@ If verification fails for any reason, some information will be printed to help | |
you debug the cause. More verbosity can be enabled by passing the global | ||
``--debug`` flag, immediately after ``ansible-sign`` in your commands. | ||
|
||
Signing and Verifying content with Sigstore | ||
=========================================== | ||
|
||
``ansible-sign`` now supports signing and verifying projects using `Sigstore <https://www.sigstore.dev/>`_. | ||
Sigstore is a new standard for signing, verifying and protecting software. | ||
It allows developers to sign artifacts using a "keyless" signing flow and to store signing materials in a tamper-resistant transparency log. | ||
|
||
----------------------- | ||
How does Sigstore work? | ||
----------------------- | ||
|
||
Sigstore signs artifacts by authentifying signers via an OpenID Connect flow, redirecting them to an identity provider such as Google, Microsoft or GitHub. | ||
When a proof of identity is obtained from one of those providers, it is used to generate an ephemeral signing certificate with Sigstore's Certificate Authority `Fulcio <https://docs.sigstore.dev/fulcio/overview/>`_. | ||
The Sigstore client then uses this certificate and an ephemeral key pair to sign the artifact, | ||
and stores the signing materials in the `Rekor <https://docs.sigstore.dev/rekor/overview/>`_ | ||
transparency log for everyone to verify the integrity and authenticity of the artifact signature. | ||
|
||
The ``ansible-sign`` command line uses the ``sigstore-python`` CLI under the hood, providing similar utilities, | ||
adapted to Ansible project signing. | ||
For further documentation about the different options available, refer to the `sigstore-python documentation <https://sigstore.github.io/sigstore-python/sigstore.html>`_ | ||
or to the client `GitHub repository <https://github.com/sigstore/sigstore-python>`_. | ||
|
||
General documentation about Sigstore can be found on `docs.sigstore.dev <https://docs.sigstore.dev/>`_. | ||
|
||
------------------------------------------------------------------------ | ||
Tutorial: signing and verifying content with `ansible-sign` and Sigstore | ||
------------------------------------------------------------------------ | ||
|
||
The Sigstore signing utility is available under the `ansible-sign project sigstore-sign` subcommands. | ||
For more information about the different command line arguments available, use ansible-sign project sigstore-sign --help`. | ||
|
||
By default, ``ansible-sign`` will use the Sigstore public good instances of Fulcio, Rekor and of the OpenID Connect issuer. | ||
If you wish to connect to private instances of Sigstore, specify the corresponding URLs with the ``--rekor-url``, ``--fulcio-url`` and ``--oidc-issuer`` options. | ||
|
||
As for the GPG signing workflow, ``ansible-sign`` generates a file containing the checksums of files specified in the project ``MANIFEST.in`` under the ``.ansible-sign/`` directory | ||
and then signs this artifact file. The siging materials generated by Sigstore (bundled in a ``sha256sum.txt.sigstore`` file) are stored under the same directory. | ||
See the :ref:`Signing Content` section of the documentation for more information on how this manifest is generated. | ||
|
||
Different options exist to authentify with an OIDC provider: | ||
If no specific command line option is specified, Sigstore will first look for `ambient credentials <https://dlorenc.medium.com/a-bit-of-ambiance-comes-to-sigstore-f80d1d6b1c30>`_ | ||
in the environment. This approach is well adapted to automated signing workflows, for example in the context of GitHub Actions. | ||
If no ambient credentials are found, the client will start an interactive browser session where the signer can authentify through | ||
a supported OIDC provider. | ||
It is also possible to directly pass an identity token obtained from an OIDC provider via the ``--identity-token`` command line option. | ||
|
||
Here is an example of the command output when using the interactive session method to authentify: | ||
|
||
.. code-block:: shell | ||
:caption: Generating a checksum manifest file and signing it with Sigstore | ||
|
||
$ ansible-sign project sigstore-sign . | ||
Waiting for browser interaction... | ||
Using ephemeral certificate: | ||
-----BEGIN CERTIFICATE----- | ||
MIICujCCAkGgAwIBAgIUEzqVrbrUo417s+8H0MsRrb9fAqcwCgYIKoZIzj0EAwMw | ||
NzEVMBMGA1UEChMMc2lnc3RvcmUuZGV2MR4wHAYDVQQDExVzaWdzdG9yZS1pbnRl | ||
cm1lZGlhdGUwHhcNMjMwMjA5MTAyNDAzWhcNMjMwMjA5MTAzNDAzWjAAMHYwEAYH | ||
KoZIzj0CAQYFK4EEACIDYgAEBL9AcKhNxgzTRUz2OfhsW+Ipw7841Ct4gCRbpsZe | ||
ipSIC0WATguVYyIhQR3T/bIZk+KbLeyhVx2oM6cMUcg342Lc/8UIL2rPini46yo2 | ||
A2hsZC2IVqgYPtKOA7u0NueBo4IBQzCCAT8wDgYDVR0PAQH/BAQDAgeAMBMGA1Ud | ||
JQQMMAoGCCsGAQUFBwMDMB0GA1UdDgQWBBQkI8srmkuqcWkY/3lC9Z956oLVLDAf | ||
BgNVHSMEGDAWgBTf0+nPViQRlvmo2OkoVaLGLhhkPzAhBgNVHREBAf8EFzAVgRNt | ||
Y29zdGFudEByZWRoYXQuY29tMCkGCisGAQQBg78wAQEEG2h0dHBzOi8vYWNjb3Vu | ||
dHMuZ29vZ2xlLmNvbTCBiQYKKwYBBAHWeQIEAgR7BHkAdwB1AN09MGrGxxEyYxke | ||
HJlnNwKiSl643jyt/4eKcoAvKe6OAAABhjW0I/QAAAQDAEYwRAIgPkB9qTeaoPwn | ||
26r0KvDN/wkuHSa6tUYE5RMlmZpOY+kCIHOUROUVEQJxgWUFDWLm6bRmWdXCZ+gD | ||
aqx+L0IYxCPEMAoGCCqGSM49BAMDA2cAMGQCMF+lOS9FZtYe5RsE08n6YmN4MTvE | ||
OlUyiCqKyZJV4jjeSn5F+icnWOF3Z7XuOTyulAIwKh2iH6SEvT8LMvpkwag1ydy/ | ||
a9fNmx6YE1hue2QQPSkAvKTUoK2d+/i1RFyjt27G | ||
-----END CERTIFICATE----- | ||
|
||
Transparency log entry created at index: 12964841 | ||
Sigstore bundle written to /home/sample-project/.ansible-sign/sha256sum.txt.sigstore | ||
|
||
The signature materials are now written under the ``.ansible-sign/`` directory of your project and the entry created in the Rekor Transparency log. Congratulations! | ||
|
||
Let's now take a look at the different ways to verify a project signed with Sigstore. | ||
``ansible-sign`` will assume that the project signing materials are always located under ``.ansible-sign/``; | ||
this is why the command should specify the path of the project root when verifying a signature. | ||
|
||
The Sigstore verify options are available under the ``ansible-sign project sigstore-verify`` subcommand, either using ``ansible-sign project sigstore-verify identity`` | ||
for projects signed by authentifying through an OIDC provider | ||
``or ansible-sign project sigstore-verify github`` for projects signed by a GitHub workflow. | ||
|
||
Verifying a project signature requires to pass the expected OIDC issuer and signer OIDC signer identity Sigstore expects to find on the signing certificate, | ||
respectively via the ``--cert-oidc-issuer`` and ``--cert-identity`` options. | ||
|
||
**Offline verification:** Sigstore supports offline verification of signatures, which means a verification without | ||
connecting to the Rekor instance where the signature entry was previously logged. | ||
This type of verification uses the Sigstore bundle ``sha256sum.txt.sigstore`` file generated while signing the artifact. | ||
and requires the ``--offline`` flag to be passed to the command. | ||
Note: while this type of verification is useful in disconnected environments, it is considered slightly weaker than the usual mode | ||
because it does not compute the `inclusion proof <https://github.com/google/trillian/blob/master/docs/TransparentLogging.md#inclusion-proofs-vs-promises>`_ | ||
of the signature entry in the transparency log. | ||
|
||
.. code-block:: shell | ||
:caption: Verifying the project signature with Sigstore | ||
|
||
$ ansible-sign project sigstore-verify identity . --cert-identity [email protected] --cert-oidc-issuer https://accounts.google.com | ||
OK: /home/sample-project/.ansible-sign/sha256sum.txt | ||
|
||
The output of the command shows that the checksums file signature was verified successfully. | ||
|
||
|
||
Notes About Automation | ||
====================== | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this true? It looks like
--oidc-issuer
has been renamed to--cert-oidc-issuer
but it still looks like it's marked required?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--cert-oidc-issuer
is the option passed to verify signatures and--oidc-issuer
the one to specify a private OIDC issuer instance for signing