keypairs/doc.go

37 lines
1.3 KiB
Go
Raw Normal View History

2019-02-21 00:10:42 +00:00
/*
Package keypairs complements Go's standard keypair-related packages
(encoding/pem, crypto/x509, crypto/rsa, crypto/ecdsa, crypto/elliptic)
with JWK encoding support and typesafe PrivateKey and PublicKey interfaces.
Basics
key, err := keypairs.ParsePrivateKey(bytesForJWKOrPEMOrDER)
pub, err := keypairs.ParsePublicKey(bytesForJWKOrPEMOrDER)
jwk, err := keypairs.MarshalJWKPublicKey(pub, time.Now().Add(2 * time.Day))
kid, err := keypairs.ThumbprintPublicKey(pub)
Convenience functions are available which will fetch keys
(or retrieve them from cache) via OIDC, .well-known/jwks.json, and direct urls.
All keys are cached by Thumbprint, as well as kid(@issuer), if available.
import "github.com/big-squid/go-keypairs/keyfetch"
pubs, err := keyfetch.OIDCJWKs("https://example.com/")
2019-02-21 00:12:31 +00:00
pubs, err := keyfetch.OIDCJWK(ThumbOrKeyID, "https://example.com/")
2019-02-21 00:10:42 +00:00
pubs, err := keyfetch.WellKnownJWKs("https://example.com/")
2019-02-21 00:12:31 +00:00
pubs, err := keyfetch.WellKnownJWK(ThumbOrKeyID, "https://example.com/")
2019-02-21 00:10:42 +00:00
pubs, err := keyfetch.JWKs("https://example.com/path/to/jwks/")
2019-02-21 00:12:31 +00:00
pubs, err := keyfetch.JWK(ThumbOrKeyID, "https://example.com/path/to/jwks/)
2019-02-21 00:10:42 +00:00
pubs, err := keyfetch.Get("https://example.com/jwk.json)
A non-caching version with the same capabilities is also available.
*/
package keypairs