Documentation
¶
Overview ¶
Package libtrust provides an interface for managing authentication and authorization using public key cryptography. Authentication is handled using the identity attached to the public key and verified through TLS x509 certificates, a key challenge, or signature. Authorization and access control is managed through a trust graph distributed between both remote trust servers and locally cached and managed data.
Index ¶
- Variables
- func AddKeySetFile(filename string, key PublicKey) error
- func GenerateCACert(signer PrivateKey, trustedKey PublicKey) (*x509.Certificate, error)
- func GenerateCACertPool(signer PrivateKey, trustedKeys []PublicKey) (*x509.CertPool, error)
- func GenerateSelfSignedClientCert(key PrivateKey) (*x509.Certificate, error)
- func GenerateSelfSignedServerCert(key PrivateKey, domains []string, ipAddresses []net.IP) (*x509.Certificate, error)
- func LoadCertificateBundle(filename string) ([]*x509.Certificate, error)
- func LoadCertificatePool(filename string) (*x509.CertPool, error)
- func NewCertAuthTLSConfig(caPath, certPath, keyPath string) (*tls.Config, error)
- func NewIdentityAuthTLSClientConfig(dockerUrl string, trustUnknownHosts bool, rootConfigPath string, ...) (*tls.Config, error)
- func NewIdentityAuthTLSConfig(trustKey PrivateKey, clients *ClientKeyManager, addr string, domain string) (*tls.Config, error)
- func SaveKey(filename string, key PrivateKey) error
- func SavePublicKey(filename string, key PublicKey) error
- type ClientKeyManager
- type JSONSignature
- func (js *JSONSignature) JWS() ([]byte, error)
- func (js *JSONSignature) Merge(others ...*JSONSignature) error
- func (js *JSONSignature) Payload() ([]byte, error)
- func (js *JSONSignature) PrettySignature(signatureKey string) ([]byte, error)
- func (js *JSONSignature) Sign(key PrivateKey) error
- func (js *JSONSignature) SignWithChain(key PrivateKey, chain []*x509.Certificate) error
- func (js *JSONSignature) Signatures() ([][]byte, error)
- func (js *JSONSignature) Verify() ([]PublicKey, error)
- func (js *JSONSignature) VerifyChains(ca *x509.CertPool) ([][]*x509.Certificate, error)
- type PrivateKey
- func FromCryptoPrivateKey(cryptoPrivateKey crypto.PrivateKey) (PrivateKey, error)
- func GenerateECP256PrivateKey() (PrivateKey, error)
- func GenerateECP384PrivateKey() (PrivateKey, error)
- func GenerateECP521PrivateKey() (PrivateKey, error)
- func GenerateRSA2048PrivateKey() (PrivateKey, error)
- func GenerateRSA3072PrivateKey() (PrivateKey, error)
- func GenerateRSA4096PrivateKey() (PrivateKey, error)
- func LoadKeyFile(filename string) (PrivateKey, error)
- func LoadOrCreateTrustKey(trustKeyPath string) (PrivateKey, error)
- func UnmarshalPrivateKeyJWK(data []byte) (PrivateKey, error)
- func UnmarshalPrivateKeyPEM(data []byte) (PrivateKey, error)
- type PublicKey
- func FilterByHosts(keys []PublicKey, host string, includeEmpty bool) ([]PublicKey, error)
- func FromCryptoPublicKey(cryptoPublicKey crypto.PublicKey) (PublicKey, error)
- func LoadKeySetFile(filename string) ([]PublicKey, error)
- func LoadPublicKeyFile(filename string) (PublicKey, error)
- func UnmarshalPublicKeyJWK(data []byte) (PublicKey, error)
- func UnmarshalPublicKeyJWKSet(data []byte) ([]PublicKey, error)
- func UnmarshalPublicKeyPEM(data []byte) (PublicKey, error)
- func UnmarshalPublicKeyPEMBundle(data []byte) ([]PublicKey, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidSignContent is used when the content to be signed is invalid. ErrInvalidSignContent = errors.New("invalid sign content") // ErrInvalidJSONContent is used when invalid json is encountered. ErrInvalidJSONContent = errors.New("invalid json content") // ErrMissingSignatureKey is used when the specified signature key // does not exist in the JSON content. ErrMissingSignatureKey = errors.New("missing signature key") )
var ( // ErrKeyFileDoesNotExist indicates that the private key file does not exist. ErrKeyFileDoesNotExist = errors.New("key file does not exist") )
Functions ¶
func AddKeySetFile ¶
AddKeySetFile adds a key to a key set
func GenerateCACert ¶
func GenerateCACert(signer PrivateKey, trustedKey PublicKey) (*x509.Certificate, error)
GenerateCACert creates a certificate which can be used as a trusted certificate authority.
func GenerateCACertPool ¶
func GenerateCACertPool(signer PrivateKey, trustedKeys []PublicKey) (*x509.CertPool, error)
GenerateCACertPool creates a certificate authority pool to be used for a TLS configuration. Any self-signed certificates issued by the specified trusted keys will be verified during a TLS handshake
func GenerateSelfSignedClientCert ¶
func GenerateSelfSignedClientCert(key PrivateKey) (*x509.Certificate, error)
GenerateSelfSignedClientCert creates a self-signed certificate for the given key which is to be used for TLS clients.
func GenerateSelfSignedServerCert ¶
func GenerateSelfSignedServerCert(key PrivateKey, domains []string, ipAddresses []net.IP) (*x509.Certificate, error)
GenerateSelfSignedServerCert creates a self-signed certificate for the given key which is to be used for TLS servers with the given domains and IP addresses.
func LoadCertificateBundle ¶
func LoadCertificateBundle(filename string) ([]*x509.Certificate, error)
LoadCertificateBundle loads certificates from the given file. The file should be pem encoded containing one or more certificates. The expected pem type is "CERTIFICATE".
func LoadCertificatePool ¶
LoadCertificatePool loads a CA pool from the given file. The file should be pem encoded containing one or more certificates. The expected pem type is "CERTIFICATE".
func NewCertAuthTLSConfig ¶
NewCertAuthTLSConfig creates a tls.Config for the server to use for certificate authentication
func NewIdentityAuthTLSClientConfig ¶
func NewIdentityAuthTLSClientConfig(dockerUrl string, trustUnknownHosts bool, rootConfigPath string, serverName string) (*tls.Config, error)
NewIdentityAuthTLSClientConfig returns a tls.Config configured to use identity based authentication from the specified dockerUrl, the rootConfigPath and the server name to which it is connecting. If trustUnknownHosts is true it will automatically add the host to the known-hosts.json in rootConfigPath.
func NewIdentityAuthTLSConfig ¶
func NewIdentityAuthTLSConfig(trustKey PrivateKey, clients *ClientKeyManager, addr string, domain string) (*tls.Config, error)
NewIdentityAuthTLSConfig creates a tls.Config for the server to use for libtrust identity authentication for the domain specified
func SaveKey ¶
func SaveKey(filename string, key PrivateKey) error
SaveKey saves the given key to a file using the provided filename. This process will overwrite any existing file at the provided location.
func SavePublicKey ¶
func SavePublicKey(filename