Skip to content

Backport test cannot-use-mTLS-cert...#1100

Merged
kkaarreell merged 1 commit into
rhel-9-mainfrom
ks_test_backport
Jul 22, 2026
Merged

Backport test cannot-use-mTLS-cert...#1100
kkaarreell merged 1 commit into
rhel-9-mainfrom
ks_test_backport

Conversation

@kkaarreell

@kkaarreell kkaarreell commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Summary by Sourcery

Tests:

  • Introduce a beakerlib regression test that validates mTLS behavior and admin authentication for verifier and registrar endpoints over HTTP and HTTPS.

@kkaarreell kkaarreell self-assigned this Jul 22, 2026
@sourcery-ai

sourcery-ai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a new Beakerlib regression test that verifies an agent’s self-signed mTLS server certificate cannot be used to access verifier/registrar admin APIs or client endpoints, and that proper certs and HTTP(S) behavior are enforced.

File-Level Changes

Change Details Files
Introduce a new regression test script to validate mTLS certificate handling and admin API access control for verifier and registrar services.
  • Set up Keylime test environment, including TPM/IMA emulators, verifier, registrar, and agent/PushAgent with configurable API version and ports.
  • Configure Keylime components via limeUpdateConf for CA, revocation notifications, tenant EK requirements, agent revocation, push attestation, and TLS paths.
  • Generate and manage distinct certificate sets for trusted client (cv_ca) and untrusted self-signed server cert used by the agent, including conditional generation for PushAgent.
  • Add test phases using openssl s_client and keylime_tenant to assert that client CA-backed certs succeed while self-signed server certs fail against verifier and registrar (with specific TLS alert expectations).
  • Add curl-based tests to confirm that verifier and registrar admin API endpoints enforce 403 Forbidden without admin auth and that registrar HTTP/HTTPS ports behave as expected (400 on HTTP, connection errors on HTTPS).
  • Implement cleanup phase to stop services/emulators, collect logs, clear data, remove generated certs, and restore configuration.
regression/cannot-use-mTLS-cert-on-server-admin-api-endpoint/test.sh
regression/cannot-use-mTLS-cert-on-server-admin-api-endpoint/main.fmf

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Several openssl x509 -text and sleep 1 | openssl s_client calls are duplicated between verifier and registrar tests; consider wrapping these into helper functions to reduce repetition and make the test easier to maintain.
  • The rlAssertGrep patterns for SSL errors and HTTP status codes (e.g. SSL alert number 48, 400 Bad Request) are quite strict; consider slightly loosening or parameterising these to avoid brittleness across minor OpenSSL/curl/version changes.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Several `openssl x509 -text` and `sleep 1 | openssl s_client` calls are duplicated between verifier and registrar tests; consider wrapping these into helper functions to reduce repetition and make the test easier to maintain.
- The `rlAssertGrep` patterns for SSL errors and HTTP status codes (e.g. `SSL alert number 48`, `400 Bad Request`) are quite strict; consider slightly loosening or parameterising these to avoid brittleness across minor OpenSSL/curl/version changes.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -0,0 +1,163 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
. /usr/share/beakerlib/beakerlib.sh || exit 1

rlPhaseStartTest "Try to open TLS connection to the verifier on port ${VERIFIER_PORT} using agent's self-signed mTLS cert"
rlRun "openssl x509 -text -in /var/lib/keylime/cv_ca/client-cert.crt"
# use sleep to ensure that it won't be client closing the connection too early
@kkaarreell

Copy link
Copy Markdown
Collaborator Author

I have executed the test with the planned keylime RHEL-9.9 update and it has passed.

@kkaarreell

Copy link
Copy Markdown
Collaborator Author

test failure is unrelated and being addressed in #1099

@kkaarreell
kkaarreell merged commit 1ed7392 into rhel-9-main Jul 22, 2026
3 of 5 checks passed
@kkaarreell
kkaarreell deleted the ks_test_backport branch July 22, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants