Skip to content

fix(nbd): regenerate TLS test certificates at build time#17142

Open
WithEnoughCoffee wants to merge 1 commit into
microsoft:tomls/base/mainfrom
WithEnoughCoffee:fix/nbd-tls-certs
Open

fix(nbd): regenerate TLS test certificates at build time#17142
WithEnoughCoffee wants to merge 1 commit into
microsoft:tomls/base/mainfrom
WithEnoughCoffee:fix/nbd-tls-certs

Conversation

@WithEnoughCoffee
Copy link
Copy Markdown

@WithEnoughCoffee WithEnoughCoffee commented May 11, 2026

The nbd 3.25 test suite ships pre-built TLS certificates that were generated on 2016-04-19 with a 10-year expiration
(expiration_days=3650), meaning they expired on 2026-04-17. This causes the tls and tlshuge tests to fail with 'Error in the certificate' from GnuTLS.

Rather than marking the tests as expected failures (the previous workaround) or backporting static certs from nbd 3.27.0 (which will expire again in 2033), regenerate all test certificates fresh at build time using certtool and the .info template files already present in the source tree. This ensures the certs are always valid regardless of when the package is built.

Changes:

  • Add BuildRequires: gnutls-utils (provides certtool)
  • Regenerate CA, server, client, and selfsigned certs in %check
  • Remove XFAIL_TESTS="tls tlshuge" workaround
  • Remove spec-search-replace overlay from nbd.comp.toml

Ref: tests/run/certs/README.md (upstream cert generation procedure) Ref: upstream fix in nbd 3.27.0 (commit 58b356b)
Precedent: rubygem-excon, libserf (Fedora specs that regenerate test certs)

Testing:
PASS: tls
PASS: tlswrongcert
PASS: tlshuge
All 19 tests passed — including tls, tlswrongcert, and tlshuge.

Merge Checklist

All boxes should be checked before merging the PR (just tick any boxes which don't apply to this PR)

  • The toolchain has been rebuilt successfully (or no changes were made to it)
  • The toolchain/worker package manifests are up-to-date
  • Any updated packages successfully build (or no packages were changed)
  • Packages depending on static components modified in this PR (Golang, *-static subpackages, etc.) have had their Release tag incremented.
  • Package tests (%check section) have been verified with RUN_CHECK=y for existing SPEC files, or added to new SPEC files
  • All package sources are available
  • cgmanifest files are up-to-date and sorted (./cgmanifest.json, ./toolkit/scripts/toolchain/cgmanifest.json, .github/workflows/cgmanifest.json)
  • LICENSE-MAP files are up-to-date (./LICENSES-AND-NOTICES/SPECS/data/licenses.json, ./LICENSES-AND-NOTICES/SPECS/LICENSES-MAP.md, ./LICENSES-AND-NOTICES/SPECS/LICENSE-EXCEPTIONS.PHOTON)
  • All source files have up-to-date hashes in the *.signatures.json files
  • sudo make go-tidy-all and sudo make go-test-coverage pass
  • Documentation has been updated to match any changes to the build system
  • Ready to merge

Summary

What does the PR accomplish, why was it needed?

Change Log
  • Change
  • Change
  • Change
Does this affect the toolchain?

YES/NO

Associated issues
  • #xxxx
Links to CVEs
Test Methodology
  • Pipeline build id: xxxx

The nbd 3.25 test suite ships pre-built TLS certificates that were
generated on 2016-04-19 with a 10-year expiration
(expiration_days=3650), meaning they expired on 2026-04-17. This
causes the tls and tlshuge tests to fail with 'Error in the
certificate' from GnuTLS.

Rather than marking the tests as expected failures (the previous
workaround) or backporting static certs from nbd 3.27.0 (which will
expire again in 2033), regenerate all test certificates fresh at
build time using certtool and the .info template files already
present in the source tree. This ensures the certs are always valid
regardless of when the package is built.

Changes:
- Add BuildRequires: gnutls-utils (provides certtool)
- Regenerate CA, server, client, and selfsigned certs in %check
- Remove XFAIL_TESTS="tls tlshuge" workaround
- Remove spec-search-replace overlay from nbd.comp.toml

Ref: tests/run/certs/README.md (upstream cert generation procedure)
Ref: upstream fix in nbd 3.27.0 (commit 58b356b)
Precedent: rubygem-excon, libserf (Fedora specs that regenerate
test certs)
Copilot AI review requested due to automatic review settings May 11, 2026 22:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Regenerates nbd’s TLS test certificates during %check to avoid failures caused by expired prebuilt certs, and removes the previous XFAIL workaround/overlay.

Changes:

  • Add BuildRequires: gnutls-utils to ensure certtool is available during builds.
  • Regenerate CA/server/client/self-signed test certs in %check and run make check without XFAIL_TESTS.
  • Remove the spec-search-replace overlay that injected the XFAIL behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
specs/n/nbd/nbd.spec Adds cert regeneration in %check, removes XFAILs, and adds gnutls-utils build requirement.
base/comps/nbd/nbd.comp.toml Removes overlay that previously marked TLS tests as expected failures.

Comment thread specs/n/nbd/nbd.spec
Comment on lines +65 to +80
pushd tests/run/certs
certtool --generate-privkey --outfile ca-key.pem 2>/dev/null
certtool --generate-self-signed --load-privkey ca-key.pem \
--template ca.info --outfile ca-cert.pem 2>/dev/null
certtool --generate-privkey --outfile server-key.pem 2>/dev/null
certtool --generate-certificate --load-ca-certificate ca-cert.pem \
--load-ca-privkey ca-key.pem --load-privkey server-key.pem \
--template server.info --outfile server-cert.pem 2>/dev/null
certtool --generate-privkey --outfile client-key.pem 2>/dev/null
certtool --generate-certificate --load-ca-certificate ca-cert.pem \
--load-ca-privkey ca-key.pem --load-privkey client-key.pem \
--template client.info --outfile client-cert.pem 2>/dev/null
certtool --generate-privkey --outfile selfsigned-key.pem 2>/dev/null
certtool --generate-self-signed --load-privkey selfsigned-key.pem \
--template ca.info --outfile selfsigned-cert.pem 2>/dev/null
popd
Comment thread specs/n/nbd/nbd.spec
Comment on lines +65 to +80
pushd tests/run/certs
certtool --generate-privkey --outfile ca-key.pem 2>/dev/null
certtool --generate-self-signed --load-privkey ca-key.pem \
--template ca.info --outfile ca-cert.pem 2>/dev/null
certtool --generate-privkey --outfile server-key.pem 2>/dev/null
certtool --generate-certificate --load-ca-certificate ca-cert.pem \
--load-ca-privkey ca-key.pem --load-privkey server-key.pem \
--template server.info --outfile server-cert.pem 2>/dev/null
certtool --generate-privkey --outfile client-key.pem 2>/dev/null
certtool --generate-certificate --load-ca-certificate ca-cert.pem \
--load-ca-privkey ca-key.pem --load-privkey client-key.pem \
--template client.info --outfile client-cert.pem 2>/dev/null
certtool --generate-privkey --outfile selfsigned-key.pem 2>/dev/null
certtool --generate-self-signed --load-privkey selfsigned-key.pem \
--template ca.info --outfile selfsigned-cert.pem 2>/dev/null
popd
Comment thread specs/n/nbd/nbd.spec
--template client.info --outfile client-cert.pem 2>/dev/null
certtool --generate-privkey --outfile selfsigned-key.pem 2>/dev/null
certtool --generate-self-signed --load-privkey selfsigned-key.pem \
--template ca.info --outfile selfsigned-cert.pem 2>/dev/null
Comment thread specs/n/nbd/nbd.spec
Comment on lines +66 to +79
certtool --generate-privkey --outfile ca-key.pem 2>/dev/null
certtool --generate-self-signed --load-privkey ca-key.pem \
--template ca.info --outfile ca-cert.pem 2>/dev/null
certtool --generate-privkey --outfile server-key.pem 2>/dev/null
certtool --generate-certificate --load-ca-certificate ca-cert.pem \
--load-ca-privkey ca-key.pem --load-privkey server-key.pem \
--template server.info --outfile server-cert.pem 2>/dev/null
certtool --generate-privkey --outfile client-key.pem 2>/dev/null
certtool --generate-certificate --load-ca-certificate ca-cert.pem \
--load-ca-privkey ca-key.pem --load-privkey client-key.pem \
--template client.info --outfile client-cert.pem 2>/dev/null
certtool --generate-privkey --outfile selfsigned-key.pem 2>/dev/null
certtool --generate-self-signed --load-privkey selfsigned-key.pem \
--template ca.info --outfile selfsigned-cert.pem 2>/dev/null
@github-actions
Copy link
Copy Markdown

🔒❌ Lock files are out of date

FIX: — run this and commit the result:

azldev component update -p nbd

Or download the fix patch and apply it:

gh run download 25700009731 -R microsoft/azurelinux -n locks-patch
git apply locks.patch

Changed components (1)

Component New upstream commit
nbd 6ba84246c2cb8e997856650b235608208a9f58e3

@github-actions
Copy link
Copy Markdown

📄❌ Rendered specs are out of date

FIX: — run this and commit the result:

azldev component render nbd

Or download the fix patch and apply it:

gh run download 25700009731 -R microsoft/azurelinux -n rendered-specs-patch
git apply rendered-specs.patch
Category Count
Content diffs 1
Extra files (untracked) 0
Missing files (deleted) 0

Content diffs

`specs/n/nbd/nbd.spec`
--- committed/specs/n/nbd/nbd.spec
+++ rendered/specs/n/nbd/nbd.spec
@@ -2,7 +2,7 @@
 ## (rpmautospec version 0.8.3)
 ## RPMAUTOSPEC: autorelease, autochangelog
 %define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
-    release_number = 8;
+    release_number = 9;
     base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
     print(release_number + base_release_number - 1);
 }%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
@@ -26,7 +26,6 @@
 BuildRequires:  gcc
 BuildRequires:  glib2-devel >= 2.26
 BuildRequires:  gnutls-devel
-BuildRequires:  gnutls-utils
 BuildRequires:  zlib-devel
 BuildRequires:  libnl3-devel
 BuildRequires:  bison
@@ -59,25 +58,6 @@
 install -pDm644 %{S:2} %{buildroot}%{_sysconfdir}/sysconfig/nbd-server
 
 %check
-# Regenerate TLS test certificates at build time so they are always valid.
-# The shipped certs (generated 2016) expired on 2026-04-17.
-# See tests/run/certs/README.md for the upstream procedure.
-pushd tests/run/certs
-certtool --generate-privkey --outfile ca-key.pem 2>/dev/null
-certtool --generate-self-signed --load-privkey ca-key.pem \
-  --template ca.info --outfile ca-cert.pem 2>/dev/null
-certtool --generate-privkey --outfile server-key.pem 2>/dev/null
-certtool --generate-certificate --load-ca-certificate ca-cert.pem \
-  --load-ca-privkey ca-key.pem --load-privkey server-key.pem \
-  --template server.info --outfile server-cert.pem 2>/dev/null
-certtool --generate-privkey --outfile client-key.pem 2>/dev/null
-certtool --generate-certificate --load-ca-certificate ca-cert.pem \
-  --load-ca-privkey ca-key.pem --load-privkey client-key.pem \
-  --template client.info --outfile client-cert.pem 2>/dev/null
-certtool --generate-privkey --outfile selfsigned-key.pem 2>/dev/null
-certtool --generate-self-signed --load-privkey selfsigned-key.pem \
-  --template ca.info --outfile selfsigned-cert.pem 2>/dev/null
-popd
 # wait longer for nbd-server to fully start,
 # one second may not be enough on Fedora building infra
 DELAY=10 make check
@@ -107,6 +87,9 @@
 
 %changelog
 ## START: Generated by rpmautospec
+* Mon May 11 2026 azldev <azldev@local> - 3.25-9
+- Local changes (uncommitted)
+
 * Thu Apr 30 2026 Daniel McIlvaney <[email protected]> - 3.25-8
 - feat: introduce deterministic commit resolution via Azure Linux lock file
 

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