Table of Contents

Method SignAsync

Namespace
SshSharp
Assembly
SshSharp.dll

SignAsync(SshPrivateKey, CancellationToken)

Signs the certificate with authority, the certificate authority's key, as ssh-keygen -s does. An RSA authority signs with rsa-sha2-512 (as ssh-keygen by default) or, when its signer offers only that, rsa-sha2-256; never with SHA-1 ssh-rsa. The signer is asked with Certificate, and the signature is checked against the authority's public key before the certificate is returned.

public Task<SshCertificate> SignAsync(SshPrivateKey authority, CancellationToken cancellationToken = default)

Parameters

authority SshPrivateKey

The authority's key: one loaded or generated, one in an SSH agent, or one a key vault, KMS or HSM holds (FromSigner(SshKeySigner, string?)).

cancellationToken CancellationToken

Cancels an agent's or a signer's signing.

Returns

Task<SshCertificate>

The certificate; write it with ToAuthorizedKeysLine() to id_ed25519-cert.pub (next to the key) or wherever the server or client reads it.

Exceptions

ArgumentException

The authority's key is paired with a certificate (an authority's key cannot itself be a certificate), or is a FIDO security key, whose signatures SshSharp cannot check.

InvalidOperationException

What the builder holds is not a valid certificate: no ValidBefore, an empty validity window, no principals or more than 256, or an invalid option, extension or value. The message says which.

CryptographicException

The authority's signature does not verify against its public key, or an SshKeySigner returned one that does not.

SshException

An SSH agent holding the authority's key refused to sign, or signed with another algorithm (an old agent that signs RSA with SHA-1); Reason is AgentFailed.