authenticode

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package authenticode checks Windows code signatures for the self-updater: the candidate must carry a valid, timestamped Authenticode signature whose leaf signer subject equals the running updater's own signer subject, so no publisher is hard-coded and a Trusted Signing certificate rotation (same subject, new key) keeps working.

Trust (chain, digest) AND the signer subject come from WinVerifyTrust: the subject is read from the leaf of the chain it validated (provider data), never from the PE's certificate bag, which lies outside the signed digest and can carry look-alike certificates. The bag is still parsed in Go to reject an ambiguous signer (two distinct certs with the signer's issuer+serial; an identical duplicate is the same cert) and to recognise an RFC 3161 timestamp WinVerifyTrust doesn't count.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsigned means the file has no Authenticode signature.
	ErrUnsigned = errors.New("authenticode: file is not signed")
	// ErrNotTimestamped means the signature has no countersignature
	// timestamp, so it stops validating when the signing cert expires.
	ErrNotTimestamped = errors.New("authenticode: signature is not timestamped")
	// ErrUntrusted means WinVerifyTrust rejected the signature.
	ErrUntrusted = errors.New("authenticode: signature not trusted")
	// ErrPublisherMismatch means the candidate's signer differs from ours.
	ErrPublisherMismatch = errors.New("authenticode: publisher differs from the running updater")
	// ErrNoPublisher means the running updater has no signer to compare
	// against (an unsigned dev build) and no test pin is configured.
	ErrNoPublisher = errors.New("authenticode: running updater is unsigned; refusing updates")
	// ErrAmbiguousSigner means the certificate bag holds more than one
	// distinct certificate matching the signer's issuer+serial (or key id).
	ErrAmbiguousSigner = errors.New("authenticode: signer certificate is ambiguous")
	// ErrUnsupported is returned off Windows, where WinVerifyTrust is absent.
	ErrUnsupported = errors.New("authenticode: verification is only supported on Windows")
)

Functions

func SamePublisher

func SamePublisher(candidate, self string) error

SamePublisher verifies candidate and checks that its leaf subject equals the subject of self (the running updater). A selfupdate_testkeys build may pin the expected subject instead (DMG_TEST_AUTHENTICODE_SUBJECT). An unsigned self with no pin refuses every candidate.

func SameSeedPublisher

func SameSeedPublisher(candidate, self string) error

SameSeedPublisher is the publisher rule for adopting an MSI seed: as SamePublisher, except that an unsigned running binary (a dev or CI build, which has no publisher to compare) accepts the seed. The seed was installed by the MSI into an admin-only directory; its copy is still checked against hashes of the source.

Types

type Signature

type Signature struct {
	Subject     string // leaf signer subject, RFC 2253 form
	Timestamped bool
}

Signature describes a file's primary Authenticode signature.

func Inspect

func Inspect(path string) (*Signature, error)

Inspect reads the primary signature of a PE file without checking trust: the bag's signer subject and whether it carries a timestamp. It is not a publisher decision (the bag is outside the signed digest); Verify uses it only to reject an ambiguous signer and to spot RFC 3161 timestamps.

func Verify

func Verify(path string) (*Signature, error)

Verify checks path with WinVerifyTrust (revocation off), takes the subject from the validated chain and requires a timestamped signature.

Jump to

Keyboard shortcuts

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