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 ¶
- func New(env *emu.Env) emu.Service
- type CertificateMapTargets
- type ForwardingRuleIPs
- type GclbTarget
- type IPConfig
- type ResourceUsers
- type Service
- func (s *Service) ApplySeed(ctx context.Context, section *yaml.Node, baseDir string) error
- func (s *Service) BackendAuthentication(ctx context.Context, name string) (*tls.Certificate, *x509.CertPool, error)
- func (s *Service) Certificate(ctx context.Context, name string) (*tls.Certificate, error)
- func (s *Service) ClockAdvanced(ctx context.Context) error
- func (s *Service) EnvVars(gw string, endpoints map[string]string) map[string]string
- func (s *Service) ExportSeed(ctx context.Context) (any, error)
- func (s *Service) MapCertificate(ctx context.Context, certificateMap, sni string) (*tls.Certificate, error)
- func (s *Service) Name() string
- func (s *Service) Operations() []emu.OperationInfo
- func (s *Service) Ready() error
- func (s *Service) Register(r emu.Router) error
- func (s *Service) Reset(ctx context.Context) error
- func (s *Service) ResourceCounts() map[string]int
- func (s *Service) Restore(ctx context.Context, dir string) error
- func (s *Service) ServerTLSPolicy(ctx context.Context, name string) (*x509.CertPool, string, error)
- func (s *Service) Snapshot(ctx context.Context, dir string) error
- func (s *Service) Start(ctx context.Context) error
- func (s *Service) Stop(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ResourceUsers ¶
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 ¶
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 ¶
Certificate implements emu.CertManager.
func (*Service) ClockAdvanced ¶
ClockAdvanced re-evaluates managed certificates.
func (*Service) EnvVars ¶
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
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) Operations ¶ added in v0.2.0
func (s *Service) Operations() []emu.OperationInfo
Operations implements emu.OperationLister.
func (*Service) Register ¶
Register installs the gRPC services, the REST surfaces and the CA admin endpoint on the gateway.
func (*Service) ResourceCounts ¶ added in v0.2.0
ResourceCounts implements emu.ResourceCounter.
func (*Service) Restore ¶ added in v0.6.0
Restore implements emu.Snapshotter: it re-evaluates the restored certificates.
func (*Service) ServerTLSPolicy ¶
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
Snapshot implements emu.Snapshotter: certificates are in the store.