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 ¶
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 ¶
Certificates lists the certificates in the user's store that have a private key.
func SigningCertificates ¶
SigningCertificates are the certificates CanSign accepts: those with non-repudiation first (a card's signature certificate), then the ones that expire last.