Skip to content

Add NX-API PKCS#12 workaround for certificate provisioning#382

Open
felix-kaestner wants to merge 5 commits into
mainfrom
fix/cert-nx-api
Open

Add NX-API PKCS#12 workaround for certificate provisioning#382
felix-kaestner wants to merge 5 commits into
mainfrom
fix/cert-nx-api

Conversation

@felix-kaestner

Copy link
Copy Markdown
Contributor

gNOI LoadCertificate on NX-OS does not support CA chains and creates immutable KeyPair entries that block rotation.

Work around both issues by encoding the certificate as PKCS#12 and importing it via NX-API CLI commands for older versions.

Also pass the CA chain to gNOI LoadCertificate for >= 10.7(1) which is expected to fix this issue (to be tested when released).

See #162

@felix-kaestner felix-kaestner requested a review from a team as a code owner May 28, 2026 14:44
@felix-kaestner felix-kaestner force-pushed the fix/cert-nx-api branch 2 times, most recently from 96c2914 to d83b434 Compare May 28, 2026 20:01
@felix-kaestner felix-kaestner marked this pull request as draft June 4, 2026 09:23
@felix-kaestner felix-kaestner marked this pull request as ready for review June 18, 2026 15:51
@felix-kaestner felix-kaestner force-pushed the fix/cert-nx-api branch 3 times, most recently from f3082a9 to 7c35426 Compare June 18, 2026 16:16
Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
The Version type was a plain string, which meant comparisons like
VersionUnknown < VersionNX10_7_1 were lexicographic and incorrect
("Unknown" > "10.7(1)"). Switch to uint8 with iota so that
relational operators reflect actual release ordering.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Append the ca.crt field (if present) to the PEM block passed to
tls.X509KeyPair so the resulting tls.Certificate contains the
full chain (leaf + intermediates + root), not just the leaf.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
gNOI LoadCertificate on NX-OS < 10.7(1) does not support CA
certificate chains and creates immutable KeyPair entries that
block rotation. Work around both issues by importing a PKCS#12
bundle via NX-API CLI for versions below 10.7(1).

The NX-API path encodes the certificate, chain, and private key
into a PKCS#12 bundle (LegacyRC2 for NX-OS compatibility), writes
it to bootflash in chunks via base64, and imports it with
crypto ca import. Existing trustpoint and keypair are cleaned up
via idempotent gNMI delete before each import.

Also passes CA certificates to gNOI LoadCertificate for the
>= 10.7(1) path so the full chain is available once that version
ships with chain support.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
@github-actions

Copy link
Copy Markdown

Merging this branch will decrease overall coverage

Impacted Packages Coverage Δ 🤖
github.com/ironcore-dev/network-operator/internal/clientutil 88.89% (-2.02%) 👎
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos 9.72% (-0.30%) 👎
github.com/ironcore-dev/network-operator/internal/transport/nxapi 68.92% (-2.91%) 👎

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/ironcore-dev/network-operator/internal/clientutil/clientutil.go 88.89% (-2.02%) 81 (+4) 72 (+2) 9 (+2) 👎
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/cert.go 2.17% (-1.16%) 46 (+16) 1 45 (+16) 👎
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/provider.go 0.05% (-0.00%) 1848 (+49) 1 1847 (+49) 👎
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/version.go 0.00% (ø) 20 (+13) 0 20 (+13)
github.com/ironcore-dev/network-operator/internal/transport/nxapi/nxapi.go 68.92% (-2.91%) 74 (+3) 51 23 (+3) 👎

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

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.

1 participant