Sign certificates with an external CA signer - #59
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
SshCertificateBuilder.SignWithsigns with the CA key's embedded private material — it rebuilds a signature from theKey. So a CA whose private key lives outside the process (a TPM or HSM) cannot sign a certificate: the exported public-onlyKeyhas no private part, and signing throwsmissing 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 anIPrivateKeySource.HostKeyAlgorithmsbacked by a TPM/HSM signer.Sign(KeyHostAlgorithm);SignWith(Key)now delegates to it viaCaHostAlgorithm(caKey), so existing behaviour (including an RSA CA signing withrsa-sha2-512) is unchanged.SignWithHostAlgorithmSelfVerifiesover 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 -Linterop cases.Version
2024.2.0.4 → 2024.2.0.5.