Skip to content
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

SECURESIGN-1014 | Add support for Trusted Timestamp Authorities in SecureSign #456

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

JasonPowr
Copy link
Contributor

@JasonPowr JasonPowr commented Jun 21, 2024

Opening this as a draft pr, so far this is just the basic deployment of the Timestamp Authority. just looking for some feedback. jira: https://issues.redhat.com/browse/SECURESIGN-1014

Testing

  1. Build and deploy operator
  2. TSA should come up with the rest of the stack
  3. Sign an image with the flag --timestamp-server-url=$TSA_URL eg
TSA_URL=https://<tsa-url>/api/v1/timestamp
cosign sign -y --timestamp-server-url=$TSA_URL <image>
  1. To verify the timestamp you need to retrieve the certificate chain using curl https://<tsa-url>/api/v1/timestamp/certchain > ts_chain.pem, then run the cosign verify cmd like so:
cosign verify --timestamp-certificate-chain=ts_chain_local.pem <image>

Copy link

openshift-ci bot commented Jun 21, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Copy link

openshift-ci bot commented Jun 21, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JasonPowr

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@JasonPowr JasonPowr force-pushed the configurable-trusted-timestamp-auth branch from 75de16f to 171b90d Compare July 2, 2024 11:29
@JasonPowr JasonPowr force-pushed the configurable-trusted-timestamp-auth branch from a0bb1a0 to 1282868 Compare July 4, 2024 11:34
@JasonPowr JasonPowr force-pushed the configurable-trusted-timestamp-auth branch from 4150c71 to 3259955 Compare July 8, 2024 07:28
@JasonPowr JasonPowr force-pushed the configurable-trusted-timestamp-auth branch 2 times, most recently from 0959e74 to 0e16cd0 Compare July 15, 2024 15:51
@JasonPowr JasonPowr force-pushed the configurable-trusted-timestamp-auth branch 3 times, most recently from 21c3783 to 080759a Compare July 18, 2024 07:22
@JasonPowr JasonPowr marked this pull request as ready for review July 18, 2024 07:22
@JasonPowr
Copy link
Contributor Author

/test tas-operator-e2e

1 similar comment
@JasonPowr
Copy link
Contributor Author

/test tas-operator-e2e

api/v1alpha1/common.go Outdated Show resolved Hide resolved
api/v1alpha1/common.go Outdated Show resolved Hide resolved
api/v1alpha1/timestampauthority_types.go Show resolved Hide resolved
api/v1alpha1/timestampauthority_types.go Outdated Show resolved Hide resolved
api/v1alpha1/timestampauthority_types.go Outdated Show resolved Hide resolved
api/v1alpha1/timestampauthority_types.go Outdated Show resolved Hide resolved
api/v1alpha1/timestampauthority_types.go Outdated Show resolved Hide resolved
api/v1alpha1/common.go Outdated Show resolved Hide resolved
@JasonPowr JasonPowr force-pushed the configurable-trusted-timestamp-auth branch from 080759a to a481720 Compare July 18, 2024 13:03
@JasonPowr JasonPowr force-pushed the configurable-trusted-timestamp-auth branch from a481720 to d53a47d Compare July 18, 2024 13:15
@JasonPowr JasonPowr force-pushed the configurable-trusted-timestamp-auth branch 2 times, most recently from c63ec3b to be06817 Compare July 24, 2024 10:29
@JasonPowr JasonPowr requested a review from osmman July 24, 2024 10:29
@JasonPowr JasonPowr force-pushed the configurable-trusted-timestamp-auth branch from be06817 to 4d8816c Compare July 26, 2024 15:11
@JasonPowr JasonPowr force-pushed the configurable-trusted-timestamp-auth branch from 4d8816c to 7e2ead7 Compare July 29, 2024 09:38
@osmman osmman requested a review from bouskaJ July 29, 2024 09:52
@JasonPowr
Copy link
Contributor Author

/test tas-operator-e2e


if ref := instance.Spec.Signer.CertificateChain.CertificateChainRef; ref == nil {
config.RootPrivateKeyPassword = common.GeneratePassword(8)
key, err := ecdsa.GenerateKey(elliptic.P384(), rand.Reader)
Copy link
Collaborator

@bouskaJ bouskaJ Jul 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything common we can share with Rekor ? Both components generate signer with all related keys.... See https://github.com/securesign/secure-sign-operator/blob/main/internal/controller/rekor/actions/server/generate_signer.go#L200

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill take a look thanks for the review :)

Copy link
Contributor

@osmman osmman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current implementation of the TSA API looks good overall.

However, I would like to request some additional changes to ensure thorough testing and integration. Firstly, please add multiple unit tests for the TSA component, focusing specifically on the generateSigner and ntpMonitoringAction actions. Our experience shows that most bugs in our operator stem from user modify values in spec, and having robust unit tests for these actions will help mitigate this issue.

Additionally, extend the current controller tests to verify that objects and resources are correctly generated. Alongside this, please create a new test case to cover the hot update scenario, ensuring that the controller handles this situation appropriately.

Lastly, modify our end-to-end (e2e) tests to integrate the new TSA component, with a particular focus on upgrade testing.

maps.Copy(secretLabels, labels)

certificateChain := k8sutils.CreateImmutableSecret(fmt.Sprintf("tsa-signer-config-%s", instance.Name), instance.Namespace, tsaCertChainConfig.ToMap(), secretLabels)
if err = controllerutil.SetControllerReference(instance, certificateChain, g.Client.Scheme()); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently I am slowly changing behavior when we should not deleting generated secrets by our operator. The reason is to keep them in cluster for key rotation and enable to users find them for validated old signed data.

So you need to modify this action:

  • by removing controllerutil.SetControllerReference and g.Client.DeleteAllOf
  • solving remove TSACertCaLabel from old secrets, is is required other wise Tuf controller will fail on error of multiple secrets. You can find inspiration in Rekor component
  • create unit tests for this action


if ntpConfig != nil {
labels := constants.LabelsFor(ComponentName, DeploymentName, instance.Name)
configMap := kubernetes.CreateConfigMap(NtpCMName, instance.Namespace, labels, map[string]string{"ntp-config.yaml": string(ntpConfig)})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is better to use immutable configmaps, the main reason is change of cfg will automatically force deployment to apply new config. You can use kubernetes.CreateImmutableConfigmap function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Tomas appreciate the review :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants