Este conteúdo não está disponível no idioma selecionado.
Chapter 2. Red Hat Enterprise Linux
2.1. Installing Trusted Artifact Signer using Ansible Copiar o linkLink copiado para a área de transferência!
You can install the Red Hat Trusted Artifact Signer (RHTAS) on Red Hat Enterprise Linux by using a Red Hat provided Ansible Playbook. This deployment gives you a basic signing framework with Keycloak as the OpenID Connect (OIDC) provider.
Red Hat recommends not to use Ansible logging in verbose or debugging mode for production environments.
For more information, see the Ansible documentation.
Prerequisites
- Red Hat Enterprise Linux version 9.4 or later.
- A Red Hat user account to access the Red Hat Hybrid Cloud Console.
Procedure
- Log in to the Red Hat Hybrid Cloud Console with your Red Hat credentials.
- From the home page, click the Services drop-down menu, and click Red Hat Ansible Automation Platform.
- From the navigational menu, expand Automation Hub, and click Collections.
- In the search field type rhtas and press enter.
- Click the artifact_signer link on the Red Hat Trusted Artifact Signer tile.
Click the Documentation tab, and follow the steps there to complete the installation of RHTAS on Red Hat Enterprise Linux.
NoteFor a detailed overview of all the configuration parameters, click the tas_single_node link under the Roles section.
2.2. Verify the Trusted Artifact Signer installation Copiar o linkLink copiado para a área de transferência!
As as systems administrator, you can verify if the deployment of Red Hat Trusted Artifact Signer (RHTAS) running on Red Hat Enterprise Linux was successful.
You can sign a test container image, and verify the authenticity of that signature to validate the deployment of RHTAS in your environment.
There are two ways to sign and three ways to verify build artifacts from your code pipeline. You can sign and verify with cosign and gitsign, but can only verify with Enterprise Contract.
2.2.1. Signing and verifying containers by using Cosign from the command-line interface Copiar o linkLink copiado para a área de transferência!
The cosign tool gives you the capability to sign and verify Open Container Initiative (OCI) container images, along with other build artifacts by using Red Hat’s Trusted Artifact Signer (RHTAS) service.
For RHTAS, you must use cosign version 2.2 or later.
Prerequisites
- Installation of RHTAS running on Red Hat Enterprise Linux 9.4 or later managed by Ansible.
-
A workstation with the
podmanbinary installed.
Procedure
Download the
cosignbinary from the local command-line interface (CLI) tool download page to your workstation.NoteThe URL address is the configured node as defined by the
tas_single_node_base_hostnamevariable. An example URL address would be,https://cli-server.example.com, given thetas_single_node_base_hostnamevalue asexample.com.- From the download page, go to the cosign download section, and click the link for your platform.
Open a terminal on your workstation, decompress the binary
.gzfile, and set the execution bit:gunzip cosign-amd64.gz chmod +x cosign-amd64
$ gunzip cosign-amd64.gz $ chmod +x cosign-amd64Copy to Clipboard Copied! Toggle word wrap Toggle overflow Move and rename the binary to a location within your
$PATHenvironment:sudo mv cosign-amd64 /usr/local/bin/cosign
$ sudo mv cosign-amd64 /usr/local/bin/cosignCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Configure your shell environment for doing container image signing and verifying.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace BASE_HOSTNAME_OF_RHTAS_SERVICE with the value of the
tas_single_node_base_hostname`variable, and replace OIDC_ISSUER_URL with your OpenID Connect (OIDC) provider’s URL string.Initialize The Update Framework (TUF) system:
cosign initialize
$ cosign initializeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Sign a test container image.
Create an empty container image:
echo "FROM scratch" > ./tmp.Dockerfile podman build . -f ./tmp.Dockerfile -t ttl.sh/rhtas/test-image:1h
$ echo "FROM scratch" > ./tmp.Dockerfile $ podman build . -f ./tmp.Dockerfile -t ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Push the empty container image to the
ttl.shephemeral registry:podman push ttl.sh/rhtas/test-image:1h
$ podman push ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Sign the container image:
cosign sign -y IMAGE_NAME:TAG
cosign sign -y IMAGE_NAME:TAGCopy to Clipboard Copied! Toggle word wrap Toggle overflow cosign sign -y ttl.sh/rhtas/test-image:1h
$ cosign sign -y ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow A web browser opens allowing you to sign the container image with an email address.
Remove the temporary Docker file:
rm ./tmp.Dockerfile
$ rm ./tmp.DockerfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verify a signed container image by using a certificate identity and issuer:
cosign verify --certificate-identity=SIGNING_EMAIL_ADDR IMAGE_NAME:TAG
cosign verify --certificate-identity=SIGNING_EMAIL_ADDR IMAGE_NAME:TAGCopy to Clipboard Copied! Toggle word wrap Toggle overflow cosign verify --certificate-identity=jdoe@redhat.com ttl.sh/rhtas/test-image:1h
$ cosign verify --certificate-identity=jdoe@redhat.com ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can also use regular expressions for the certificate identity and issuer by using the following options to the
cosigncommand,--certificate-identity-regexpand--certificate-oidc-issuer-regexp.Download the
rekor-clibinary from the local command-line interface (CLI) tool download page to your workstation.Open a web browser, and go to the CLI server web page.
NoteThe URL address is the configured node as defined by the
tas_single_node_base_hostnamevariable. An example URL address would be,https://cli-server.example.com, given that the value oftas_single_node_base_hostnameisexample.com.- From the download page, go to the rekor-cli download section, and click the link for your platform.
Open a terminal on your workstation, decompress the binary
.gzfile, and set the execution bit:gunzip rekor-cli-amd64.gz chmod +x rekor-cli-amd64
$ gunzip rekor-cli-amd64.gz $ chmod +x rekor-cli-amd64Copy to Clipboard Copied! Toggle word wrap Toggle overflow Move and rename the binary to a location within your
$PATHenvironment:sudo mv rekor-cli-amd64 /usr/local/bin/rekor-cli
$ sudo mv rekor-cli-amd64 /usr/local/bin/rekor-cliCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Query the transparency log by using the Rekor command-line interface.
Search based on the log index:
rekor-cli get --log-index 0 --rekor_server $COSIGN_REKOR_URL --format json | jq
$ rekor-cli get --log-index 0 --rekor_server $COSIGN_REKOR_URL --format json | jqCopy to Clipboard Copied! Toggle word wrap Toggle overflow Search for an email address to get the universal unique identifier (UUID):
rekor-cli search --email SIGNING_EMAIL_ADDR --rekor_server $COSIGN_REKOR_URL --format json | jq
rekor-cli search --email SIGNING_EMAIL_ADDR --rekor_server $COSIGN_REKOR_URL --format json | jqCopy to Clipboard Copied! Toggle word wrap Toggle overflow rekor-cli search --email jdoe@redhat.com --rekor_server $COSIGN_REKOR_URL --format json | jq
$ rekor-cli search --email jdoe@redhat.com --rekor_server $COSIGN_REKOR_URL --format json | jqCopy to Clipboard Copied! Toggle word wrap Toggle overflow This command returns the UUID for use with the next step.
Use the UUID to get the transaction details:
rekor-cli get --uuid UUID --rekor_server $COSIGN_REKOR_URL --format json | jq
rekor-cli get --uuid UUID --rekor_server $COSIGN_REKOR_URL --format json | jqCopy to Clipboard Copied! Toggle word wrap Toggle overflow rekor-cli get --uuid 24296fb24b8ad77a71b9c1374e207537bafdd75b4f591dcee10f3f697f150d7cc5d0b725eea641e7 --rekor_server $COSIGN_REKOR_URL --format json | jq
$ rekor-cli get --uuid 24296fb24b8ad77a71b9c1374e207537bafdd75b4f591dcee10f3f697f150d7cc5d0b725eea641e7 --rekor_server $COSIGN_REKOR_URL --format json | jqCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.2.2. Signing and verifying commits by using Gitsign from the command-line interface Copiar o linkLink copiado para a área de transferência!
The gitsign tool gives you the ability to sign and verify Git repository commits by using Red Hat’s Trusted Artifact Signer (RHTAS) service.
Prerequisites
- Installation of RHTAS running on Red Hat Enterprise Linux 9.4 or later managed by Ansible.
A workstation with the
git, andcosignbinaries installed.-
You must use
cosignversion 2.2 or later.
-
You must use
- A locally cloned Git repository.
Procedure
Download the
gitsignbinary from the local command-line interface (CLI) tool download page to your workstation.NoteThe URL address is the configured node as defined by the
tas_single_node_base_hostnamevariable. An example URL address would be,https://cli-server.example.com, given thetas_single_node_base_hostnamevalue asexample.com.- From the download page, go to the gitsign download section, and click the link for your platform.
Open a terminal on your workstation, decompress the .gz file, and set the execution bit:
gunzip gitsign-amd64.gz chmod +x gitsign-amd64
$ gunzip gitsign-amd64.gz $ chmod +x gitsign-amd64Copy to Clipboard Copied! Toggle word wrap Toggle overflow Move and rename the binary to a location within your
$PATHenvironment:sudo mv gitsign-amd64 /usr/local/bin/gitsign
$ sudo mv gitsign-amd64 /usr/local/bin/gitsignCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Configure your shell environment for doing commit signing and verifying.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace BASE_HOSTNAME_OF_RHTAS_SERVICE with the value of the
tas_single_node_base_hostname`variable, and replace OIDC_ISSUER_URL with your OpenID Connect (OIDC) provider’s URL string.-
Change directory (
cd) to the local Git repository directory. Configure the local repository configuration to sign your commits by using the RHTAS service:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Make a commit to the local repository:
git commit --allow-empty -S -m "Test of a signed commit"
$ git commit --allow-empty -S -m "Test of a signed commit"Copy to Clipboard Copied! Toggle word wrap Toggle overflow A web browser opens allowing you to sign the commit with an email address.
Initialize The Update Framework (TUF) system:
cosign initialize
$ cosign initializeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the commit:
gitsign verify --certificate-identity=SIGNING_EMAIL --certificate-oidc-issuer=$SIGSTORE_OIDC_ISSUER HEAD
gitsign verify --certificate-identity=SIGNING_EMAIL --certificate-oidc-issuer=$SIGSTORE_OIDC_ISSUER HEADCopy to Clipboard Copied! Toggle word wrap Toggle overflow gitsign verify --certificate-identity=jdoe@redhat.com --certificate-oidc-issuer=$SIGSTORE_OIDC_ISSUER HEAD
$ gitsign verify --certificate-identity=jdoe@redhat.com --certificate-oidc-issuer=$SIGSTORE_OIDC_ISSUER HEADCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.2.3. Verifying signatures on container images with Conforma Copiar o linkLink copiado para a área de transferência!
Conforma, formally known as Enterprise Contract (EC), is a tool for maintaining the security of software supply chains, and you can use it to define and enforce policies for container images. You can use the ec binary to verify the attestation and signature of container images that use Red Hat’s Trusted Artifact Signer (RHTAS) signing framework.
Prerequisites
- Installation of RHTAS running on Red Hat Enterprise Linux 9.4 or later managed by Ansible.
A workstation with the
cosign, andpodmanbinaries installed.-
You must use
cosignversion 2.2 or later.
-
You must use
Procedure
Download the
ecbinary from the local command-line interface (CLI) tool download page to your workstation.NoteThe URL address is the configured node as defined by the
tas_single_node_base_hostnamevariable. An example URL address would be,https://cli-server.example.com, given thetas_single_node_base_hostnamevalue asexample.com.- From the download page, go to the ec download section, and click the link for your platform.
Open a terminal on your workstation, decompress the binary .gz file, and set the execution bit:
gunzip ec-amd64.gz chmod +x ec-amd64
$ gunzip ec-amd64.gz $ chmod +x ec-amd64Copy to Clipboard Copied! Toggle word wrap Toggle overflow Move and rename the binary to a location within your
$PATHenvironment:sudo mv ec-amd64 /usr/local/bin/ec
$ sudo mv ec-amd64 /usr/local/bin/ecCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Configure your shell environment for doing container image signing and verifying.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace BASE_HOSTNAME_OF_RHTAS_SERVICE with the value of the
tas_single_node_base_hostname`variable, and replace OIDC_ISSUER_URL with your OpenID Connect (OIDC) provider’s URL string.Initialize The Update Framework (TUF) system:
cosign initialize
$ cosign initializeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Sign a test container image.
Create an empty container image:
echo "FROM scratch" > ./tmp.Dockerfile podman build . -f ./tmp.Dockerfile -t ttl.sh/rhtas/test-image:1h
$ echo "FROM scratch" > ./tmp.Dockerfile $ podman build . -f ./tmp.Dockerfile -t ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Push the empty container image to the
ttl.shephemeral registry:podman push ttl.sh/rhtas/test-image:1h
$ podman push ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Sign the container image:
cosign sign -y IMAGE_NAME:TAG
cosign sign -y IMAGE_NAME:TAGCopy to Clipboard Copied! Toggle word wrap Toggle overflow cosign sign -y ttl.sh/rhtas/test-image:1h
$ cosign sign -y ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow A web browser opens allowing you to sign the container image with an email address.
Remove the temporary Docker file:
rm ./tmp.Dockerfile
$ rm ./tmp.DockerfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Create a
predicate.jsonfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Refer to the SLSA provenance predicate specifications for more information about the schema layout.
Associate the
predicate.jsonfile with the container image:cosign attest -y --predicate ./predicate.json --type slsaprovenance IMAGE_NAME:TAG
cosign attest -y --predicate ./predicate.json --type slsaprovenance IMAGE_NAME:TAGCopy to Clipboard Copied! Toggle word wrap Toggle overflow cosign attest -y --predicate ./predicate.json --type slsaprovenance ttl.sh/rhtas/test-image:1h
$ cosign attest -y --predicate ./predicate.json --type slsaprovenance ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the container image has at least one attestation and signature:
cosign tree IMAGE_NAME:TAG
cosign tree IMAGE_NAME:TAGCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the container image by using Conforma:
ec validate image --image IMAGE_NAME:TAG --certificate-identity-regexp 'SIGNER_EMAIL_ADDR' --certificate-oidc-issuer-regexp 'keycloak-system' --output yaml --show-successes
ec validate image --image IMAGE_NAME:TAG --certificate-identity-regexp 'SIGNER_EMAIL_ADDR' --certificate-oidc-issuer-regexp 'keycloak-system' --output yaml --show-successesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enterprise Contract generates a pass-fail report with details on any security violations. When you add the
--infoflag, the report includes more details and possible solutions for any violations found.