mtls

package
v0.0.0-...-451182e Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 14 Imported by: 2 modules, 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 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 CheckPeer

func CheckPeer(ctx context.Context, name string) error

CheckPeer tells whether the caller's certificate carries name.

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

func PeerNames(ctx context.Context) []string

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

type Files struct {
	Cert string `yaml:"cert"`
	Key  string `yaml:"key"`
	CA   string `yaml:"ca"`
}

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

func (f Files) Enabled() (bool, error)

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.

func (Files) Validate

func (f Files) Validate() error

Validate fails when mutual TLS is half configured or its files can't be used. A server calls it at startup, so that a broken production setup stops it and doesn't surface at the first handshake.

Jump to

Keyboard shortcuts

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