Skip to content

Sign certificates with an external CA signer - #59

Merged
darinkes merged 1 commit into
mainfrom
feat/certificate-external-signer
Jul 22, 2026
Merged

Sign certificates with an external CA signer#59
darinkes merged 1 commit into
mainfrom
feat/certificate-external-signer

Conversation

@darinkes

Copy link
Copy Markdown
Owner

Why

SshCertificateBuilder.SignWith signs with the CA key's embedded private material — it rebuilds a signature from the Key. So a CA whose private key lives outside the process (a TPM or HSM) cannot sign a certificate: the exported public-only Key has no private part, and signing throws missing private key.

Changes

  • SignWith(KeyHostAlgorithm caAlgorithm) — new overload that signs through the algorithm's own signer, so the CA key is never exported. Pass, for example, the first entry of an IPrivateKeySource.HostKeyAlgorithms backed by a TPM/HSM signer.
  • The signing body is factored into a private Sign(KeyHostAlgorithm); SignWith(Key) now delegates to it via CaHostAlgorithm(caKey), so existing behaviour (including an RSA CA signing with rsa-sha2-512) is unchanged.
  • New test SignWithHostAlgorithmSelfVerifies over RSA/ECDSA/ED25519 CAs, driving the external-signer path.

Testing

Full certificate suite (28 tests) passes on net48 and net8.0, including the ssh-keygen -L interop cases.

Version

2024.2.0.4 → 2024.2.0.5.

SshCertificateBuilder.SignWith signed with the CA key's embedded private
material, so a CA whose private key lives outside the process — in a TPM
or HSM — could not sign a certificate: the public-only Key has no private
part. Add SignWith(KeyHostAlgorithm), which signs through the algorithm's
own signer and never needs the private key; SignWith(Key) delegates to it,
so existing behaviour is unchanged.

Bump to 2024.2.0.5.
@darinkes
darinkes merged commit 6cc77da into main Jul 22, 2026
2 checks passed
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.

1 participant