winsign

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 6 Imported by: 1 module, 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 winsign signs with the keys in the Windows certificate store, smart cards (CAC, PIV) included, through CNG. It needs no cgo: the calls go straight to crypt32.dll and ncrypt.dll.

certs, err := winsign.Certificates()      // the user's signing certificates
signer, err := certs[0].Signer()          // Windows asks for the card's PIN when it signs
defer signer.Close()
signed, err := form.Sign(xfa.SignOptions{Field: som, Signer: signer, Chain: certs[0].Chain})

On other systems Certificates returns ErrUnsupported.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = errors.New("winsign: the Windows certificate store is only on Windows")

ErrUnsupported is returned off Windows.

Functions

func CanSign

func CanSign(c *x509.Certificate) bool

CanSign says whether a certificate is for signing documents: valid now, with a digital signature or non-repudiation key usage, and, when it lists extended key usages, one for signing documents or e-mail. That leaves out a card's authentication and card-authentication certificates, its encryption certificate, and TLS certificates.

Types

type Cert

type Cert struct {
	Certificate *x509.Certificate
	// Chain is the certificate first, then its issuers, as far as Windows
	// can build the chain from what's installed (nothing is fetched).
	Chain []*x509.Certificate
	// contains filtered or unexported fields
}

Cert is a certificate in the user's store that has a private key.

func Certificates

func Certificates() ([]*Cert, error)

Certificates lists the certificates in the user's store that have a private key.

func SigningCertificates

func SigningCertificates() ([]*Cert, error)

SigningCertificates are the certificates CanSign accepts: those with non-repudiation first (a card's signature certificate), then the ones that expire last.

func (*Cert) Signer

func (c *Cert) Signer() (Signer, error)

Signer opens the certificate's private key for signing.

type Signer

type Signer interface {
	crypto.Signer
	Close() error
}

Signer is a crypto.Signer for a certificate's key. Close it when done.

Jump to

Keyboard shortcuts

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