replycerts

package
v0.10.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package replycerts provisions and retains FileVault encryption identities.

Design

Prepare generates an RSA certificate and private key entirely in Go, persists them, then supplies the DER certificate to RotateFileVaultKey. Personal rotations use ReplyEncryptionCertificate; institutional rotations use NewCertificate. No shell command or operating-system certificate tool is used. EscrowProfile prepares an InstallProfile command with a FileVault recovery-key escrow payload referencing its generated certificate in the same profile.

Enrollment identity and command UUID bind each key to its command. Atomic state updates make concurrent retries reuse the same identity and reject conflicting command bodies or externally supplied certificates. New commands receive separate keys. Persistent adapters must encrypt records at rest.

Recipient retrieves the retained key for privileged response processing, even after certificate expiry. Forget is explicit: retain escrow identities while their profiles or encrypted keys remain in use, and retain command identities until all replies are recovered or deliberately abandoned. Automatic expiry must not destroy decryption keys. The reference server prepares certificates before enqueueing through its administrative API. Embedders call Prepare or EscrowProfile before Core.Enqueue.

References

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalid  = errors.New("replycerts: invalid command or stored identity")
	ErrConflict = errors.New(
		"replycerts: command identity or encryption certificate conflicts with workflow",
	)
)

Errors deliberately omit certificate, password and private-key bytes.

Functions

This section is empty.

Types

type Manager

type Manager struct{ Store state.Store }

Manager creates one RSA certificate per command. Concurrent/retried prepares select the same persisted key. New commands get new keys automatically. A certificate is never renewed in place after binding it to a command.

func (*Manager) EscrowProfile

func (m *Manager) EscrowProfile(
	ctx context.Context,
	id mdm.EnrollmentID,
	commandUUID, identifier, location string,
) (*mdm.Command, error)

EscrowProfile prepares an InstallProfile command containing a system-scoped FileVault recovery-key escrow payload and its automatically generated RSA certificate. Retain commandUUID to retrieve the matching Recipient. Repeating the same request preserves the certificate and every payload UUID.

On macOS 26, installing this profile can rotate an existing personal recovery key automatically when a bootstrap token is present. The caller must establish those prerequisites, check for an existing escrow profile, and arrange secure retrieval through SecurityInfo. Removing the profile does not restore a prior recovery key. Keep this binding while the profile or its encrypted keys exist. https://support.apple.com/en-us/124963 https://developer.apple.com/documentation/devicemanagement/fderecoverykeyescrow

func (*Manager) Forget

func (m *Manager) Forget(ctx context.Context, id mdm.EnrollmentID, commandUUID string) error

Forget removes a settled workflow's key. The caller must first save the recovered secret in persistent storage and rule out pending/replayed responses, or deliberately abandon the command. There is intentionally no age-based automatic deletion. For escrow profiles, retain the binding while the profile remains installed or any encrypted recovery key still depends on it, regardless of command status.

func (*Manager) Prepare

func (m *Manager) Prepare(
	ctx context.Context,
	id mdm.EnrollmentID,
	command *mdm.Command,
) (*mdm.Command, error)

Prepare fills ReplyEncryptionCertificate for a personal-key rotation, or NewCertificate for an institutional-key rotation, before queueing. It rejects externally supplied encryption certificates. A retry may include the exact certificate already generated by this workflow. Other commands pass through. The enrollment and command UUID bind the retained key to the intended reply.

func (*Manager) Recipient

func (m *Manager) Recipient(
	ctx context.Context,
	id mdm.EnrollmentID,
	commandUUID string,
) (*x509.Certificate, crypto.Decrypter, error)

Recipient loads the exact retained certificate/key after an authenticated response. Pass them to cms.DecryptEnvelope for EncryptedNewRecoveryKey or the CMS envelope produced by a profile prepared with EscrowProfile. This privileged API must never be exposed as an administrative key export.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL