Documentation
¶
Overview ¶
Package mtls builds the gRPC credentials for the link between gocast and the runners.
Both directions use mutual TLS: the runner dials gocast to register and report, gocast dials the runner to hand out jobs. A peer is identified by the DNS names in its certificate, never by its address: on the overlay network the address and the container name change all the time.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fingerprint ¶
func Fingerprint(c *x509.Certificate) string
Fingerprint is the SHA-256 of the certificate's DER encoding, in hex.
func PeerCert ¶
func PeerCert(ctx context.Context) *x509.Certificate
PeerCert returns the verified certificate of the caller, or nil when the connection is not TLS.
func PeerNames ¶
PeerNames returns the DNS names in the verified certificate of the caller, or nil when the connection is not TLS.
func RequirePeer ¶
func RequirePeer(name string) grpc.UnaryServerInterceptor
RequirePeer rejects every call whose certificate does not carry name. It keeps a runner's certificate, which the same CA signed, from being used to call another runner.
Types ¶
type Files ¶
Files are the paths of a PEM certificate, its key and the CA that signs the peers.
func (Files) ClientCredentials ¶
func (f Files) ClientCredentials(serverName string) (credentials.TransportCredentials, error)
ClientCredentials verifies the server's certificate against serverName, which is the name the peer is registered under and not necessarily the name that is dialed.
func (Files) Enabled ¶
Enabled tells whether mutual TLS is configured. Nothing set means off, which is how local development runs; a partial setting is an error, so that a typo in production can't silently leave the link in plaintext.
func (Files) ServerCredentials ¶
func (f Files) ServerCredentials() (credentials.TransportCredentials, error)
ServerCredentials makes the server require and verify a client certificate.