certs

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 48 Imported by: ? 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 certs emulates Certificate Manager (certificatemanager.googleapis.com v1) and the Network Security API (networksecurity.googleapis.com v1: backend authentication configs, server and client TLS policies) and provides emu.CertManager, the view of those resources the load balancer data plane consumes (FR-LB-004, FR-LB-006, FR-LB-009).

Both APIs are served over gRPC (the official Go clients) and REST (gcloud, OpenTofu) on the gateway; mutations are google.longrunning operations (internal/lro). Resources are stored in their REST JSON form, which tracks the current googleapis protos (decision 11.3) — e.g. TrustConfig.allowlistedCertificates and certificate scope CLIENT_AUTH, which the published Go gRPC stubs do not carry yet; over gRPC such fields are omitted.

Managed certificates are issued by the instance CA (env.CA, Section 7.4) once their domains are authorized (certificates.go).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(env *emu.Env) emu.Service

New returns the service.

Types

type CertificateMapTargets

type CertificateMapTargets interface {
	CertificateMapTargets(ctx context.Context, certificateMap string) []GclbTarget
}

CertificateMapTargets is optionally implemented by the "lb" service: the target proxies (and their forwarding rule addresses) that reference a certificate map ("projects/P/locations/global/certificateMaps/M"). It populates CertificateMap.gclbTargets.

type ForwardingRuleIPs

type ForwardingRuleIPs interface {
	ForwardingRuleIPs(ctx context.Context, project string) []string
}

ForwardingRuleIPs is optionally implemented by the "lb" service for load balancer authorization of managed certificates: the IP addresses of the project's forwarding rules.

type GclbTarget

type GclbTarget struct {
	// TargetHTTPSProxy or TargetSSLProxy is the proxy's relative name
	// ("projects/P/global/targetHttpsProxies/X").
	TargetHTTPSProxy string
	TargetSSLProxy   string
	IPConfigs        []IPConfig
}

GclbTarget describes a target proxy that serves a certificate map, as reported in CertificateMap.gclbTargets.

type IPConfig

type IPConfig struct {
	IPAddress string
	Ports     []int64
}

IPConfig is one forwarding rule address of a GclbTarget.

type ResourceUsers

type ResourceUsers interface {
	CertsResourceUsers(ctx context.Context, name string) []string
}

ResourceUsers is optionally implemented by the "lb" service: the selfLinks of load balancer resources (target proxies, backend services) that reference a Certificate Manager or Network Security resource (relative name). Referenced resources cannot be deleted, and certificates report them in usedBy.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the certs service module.

func (*Service) ApplySeed

func (s *Service) ApplySeed(ctx context.Context, section *yaml.Node, baseDir string) error

ApplySeed implements emu.Seeder (FR-CORE-011) for the "certs" section. Each list holds resources in their REST JSON shape plus addressing keys (name, or project/location/id; certificateMap for entries). A key ending in "File" is replaced by the contents of that file, relative to the seed file, e.g. pemCertificateFile → pemCertificate. References given as a bare ID are expanded within the resource's project and location. Seeding is idempotent: existing resources are updated.

certs:
  trustConfigs:
    - {project: p, id: backends, trustStores: [{trustAnchors: [{pemCertificateFile: ca.pem}]}]}
  dnsAuthorizations:
    - {project: p, id: example, domain: example.test}
  certificates:
    - project: p
      id: web
      selfManaged: {pemCertificateFile: web.pem, pemPrivateKeyFile: web-key.pem}
    - {project: p, id: managed, managed: {domains: [app.example.test], dnsAuthorizations: [example]}}
    - {project: p, id: lb-client, scope: CLIENT_AUTH, selfManaged: {...}}
  certificateMaps:
    - {project: p, id: web}
  certificateMapEntries:
    - {project: p, certificateMap: web, id: app, hostname: app.example.test, certificates: [web]}
  backendAuthenticationConfigs:
    - {project: p, id: mtls, clientCertificate: lb-client, trustConfig: backends}
  serverTlsPolicies:
    - {project: p, id: frontend, mtlsPolicy: {clientValidationMode: REJECT_INVALID, clientValidationTrustConfig: backends}}

func (*Service) BackendAuthentication

func (s *Service) BackendAuthentication(ctx context.Context, name string) (*tls.Certificate, *x509.CertPool, error)

BackendAuthentication implements emu.CertManager. roots holds the trust config's anchors (plus intermediates that chain to them and allowlisted certificates); with wellKnownRoots PUBLIC_ROOTS it also holds the system roots and the instance CA, which plays the role of the public CAs for emulated workloads. NONE without a trust config yields an empty pool.

func (*Service) Certificate

func (s *Service) Certificate(ctx context.Context, name string) (*tls.Certificate, error)

Certificate implements emu.CertManager.

func (*Service) ClockAdvanced

func (s *Service) ClockAdvanced(ctx context.Context) error

ClockAdvanced re-evaluates managed certificates.

func (*Service) EnvVars

func (s *Service) EnvVars(gw string, endpoints map[string]string) map[string]string

EnvVars implements emu.EnvVarer (FR-CORE-004): gcloud endpoint overrides for `gcloud certificate-manager` and `gcloud network-security`.

func (*Service) ExportSeed added in v0.6.0

func (s *Service) ExportSeed(ctx context.Context) (any, error)

ExportSeed implements emu.SeedExporter (FR-CORE-013). Self-managed certificates are written with their PEM chain and private key inline; managed certificates are written as requested and are provisioned again when applied. References within the resource's project and location are shortened to bare IDs.

func (*Service) MapCertificate

func (s *Service) MapCertificate(ctx context.Context, certificateMap, sni string) (*tls.Certificate, error)

MapCertificate implements emu.CertManager.

func (*Service) Name

func (s *Service) Name() string

func (*Service) Operations added in v0.2.0

func (s *Service) Operations() []emu.OperationInfo

Operations implements emu.OperationLister.

func (*Service) Ready

func (s *Service) Ready() error

func (*Service) Register

func (s *Service) Register(r emu.Router) error

Register installs the gRPC services, the REST surfaces and the CA admin endpoint on the gateway.

func (*Service) Reset

func (s *Service) Reset(ctx context.Context) error

Reset drops pending operations, waiting for running ones (#301), stops a provisioning pass in flight, waiting for it (#307), and drops cached certificates; the store is reset by the instance, and the provisioner runs again from ResetDone.

func (*Service) ResetDone added in v0.9.0

func (s *Service) ResetDone()

ResetDone runs the provisioner again once the store is reset too.

func (*Service) ResourceCounts added in v0.2.0

func (s *Service) ResourceCounts() map[string]int

ResourceCounts implements emu.ResourceCounter.

func (*Service) Restore added in v0.6.0

func (s *Service) Restore(ctx context.Context, dir string) error

Restore implements emu.Snapshotter: it re-evaluates the restored certificates.

func (*Service) ServerTLSPolicy

func (s *Service) ServerTLSPolicy(ctx context.Context, name string) (*x509.CertPool, string, error)

ServerTLSPolicy implements emu.CertManager. A policy without mtlsPolicy returns a nil pool and mode "" (do not request client certificates).

func (*Service) Snapshot added in v0.6.0

func (s *Service) Snapshot(ctx context.Context, dir string) error

Snapshot implements emu.Snapshotter: certificates are in the store.

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

Start runs the managed-certificate provisioner, its first pass at once.

func (*Service) Stop

func (s *Service) Stop(ctx context.Context) error

Stop stops the provisioner and pending operations.

Jump to

Keyboard shortcuts

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