Documentation
¶
Index ¶
Constants ¶
const ( // FileMode is the mode of an installed KRL, which is read-only as // nothing but [Verified.Install] should change it FileMode fs.FileMode = 0440 )
const Namespace = "krl@com.github.serverless-ssh-ca.andrewheberle"
Namespace is the SSHSIG namespace the CA signs KRLs with
Variables ¶
var ( // ErrInvalidSignature is returned when the signature on the KRL cannot be // decoded or does not verify with the CA public key ErrInvalidSignature = errors.New("krl signature verification failed") // ErrNoPublicKey is returned when no CA public key is provided to verify // the signature on the KRL with ErrNoPublicKey = errors.New("no public key provided for signature verification") // ErrOlderKRL is returned when the KRL is older than an existing KRL ErrOlderKRL = errors.New("krl is older than the existing krl") // ErrUnexpectedCA is returned when a certificate section of the KRL is not // for the CA, including sections that apply to any CA ErrUnexpectedCA = errors.New("encountered krl certificate section with unexpected CA") // ErrUnexpectedSection is returned when the KRL contains a section that // does not revoke certificates, such as one revoking explicit keys ErrUnexpectedSection = errors.New("encountered unexpected section type in krl") // ErrUnexpectedType is returned when the KRL, or the KRL already // installed, names a certificate type other than the one requested ErrUnexpectedType = errors.New("krl is for an unexpected certificate type") // ErrUntypedKRL is returned when the KRL does not name its certificate // type but the KRL already installed does. Once a CA names the type, an // untyped KRL comes from a downgraded CA or is an older KRL replayed, // which may be for the other type. ErrUntypedKRL = errors.New("krl does not name its certificate type, but the existing krl does") )
Functions ¶
This section is empty.
Types ¶
type CertificateType ¶ added in v0.23.1
type CertificateType string
CertificateType is the type of certificate a KRL revokes
const ( // User is the KRL for user certificates User CertificateType = "user" // Host is the KRL for host certificates Host CertificateType = "host" )
type Outcome ¶ added in v0.25.1
type Outcome int
Outcome is the result of a successful Verified.Install
const ( // Written means the KRL was written, replacing any older KRL Written Outcome = iota // Unchanged means the file already held the KRL with [FileMode], so it // was not written Unchanged // ReplacedUnparseable means the file held something that could not be // parsed as a KRL, so it was replaced ReplacedUnparseable )
type Verified ¶ added in v0.25.1
type Verified struct {
// contains filtered or unexported fields
}
Verified is a KRL whose signature has been verified with the CA public key, that only revokes certificates issued by that CA, and that is for the certificate type requested or doesn't name one. It can only be obtained from Fetch.
func Fetch ¶ added in v0.25.1
func Fetch(ctx context.Context, server string, certificatetype CertificateType, pub ssh.PublicKey, opts ...api.ClientOption) (*Verified, error)
Fetch retrieves the KRL for certificatetype from server and verifies it with pub, which must be the public key of the CA. Requests use the client from httpclient.New unless opts sets another with api.WithHTTPClient.
func (*Verified) Generated ¶ added in v0.25.1
Generated returns the time the KRL was generated by the CA
func (*Verified) Install ¶ added in v0.25.1
Install atomically writes the KRL to path with FileMode. A KRL older than one already at path is never installed, so a previously issued KRL cannot un-revoke certificates; an error wrapping ErrOlderKRL is returned and the file is left alone. KRLs are compared by version and then by the date they were generated, as the CA does not increase the version for each KRL.
The KRL at path must also be for the same certificate type, or not name one, or an error wrapping ErrUnexpectedType is returned. Once a KRL naming its type is installed, a KRL that doesn't is refused with an error wrapping ErrUntypedKRL. In either case the file is left alone. Both are checked before the version.
func (*Verified) Typed ¶ added in v1.1.0
Typed reports whether the KRL names its certificate type, which CAs after 1.0.2 sign into its comment. A KRL that does not can be the other type's, so Verified.Install only installs one where no typed KRL is.