Files
ca/Documentation/api/server_service_ca.md
2026-10-31 05:36:03 -05:00

15 KiB

ca

import "github.com/effective-security/trustyca/server/service/ca"

Package ca implements the CA service of the tenants (pb.CA): the CA API of the users and the API keys of an org on the wfe listener (DESIGN.md section 2.1). The public requests carry no OrgID: the org is the org of the caller's token.

The service holds no issuer key and reads no CA table: every method copies the public request into its privpb counterpart, with the org of the token in OrgID, and forwards it with the caller's context to the backend service (server/service/backend, privpb.Backend). It finds the backend through a shared.BackendLocator: the backend service of the same process, else the backend listener with the `ca` service client. A precondition refusal of a remote backend is HTTP 409 conflict again (forwardedError).

The service is built by its Factory from the app container; a test wires it to a backend:

svc := ca.New(shared.NewStaticBackendLocator(backendSvc))
res, err := svc.SignCertificate(ctx, &pb.SignCertificateRequest{
	Profile: "server",
	Request: csrPEM,
})

Index

Constants

ServiceName provides the Service Name for this package

const ServiceName = "ca"

func Factory

func Factory(server gserver.GServer) any

Factory returns a factory of the service

type Service

Service defines the CA service (pb.CA) of the tenants: the users and the API keys of an org. It holds no issuer key and reads no CA table: every method copies the public request into its privpb counterpart with the org of the caller's token and forwards it to the backend service (server/service/backend, DESIGN.md section 2.1), in process when this process runs it, else over gRPC with the `ca` service client, with the context of the caller.

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

func New

func New(backend *shared.BackendLocator) *Service

New returns the service that forwards to the backend the locator finds; without a locator every method is Unavailable

func (*Service) ActivateIssuer

func (s *Service) ActivateIssuer(ctx context.Context, req *pb.ActivateIssuerRequest) (*pb.Issuer, error)

ActivateIssuer activates a Pending issuer (Backend.ActivateIssuer)

func (*Service) Close

func (s *Service) Close()

Close the subservices and its resources

func (*Service) DeleteProfile

func (s *Service) DeleteProfile(ctx context.Context, req *pb.DeleteProfileRequest) (*emptypb.Empty, error)

DeleteProfile deletes a profile of the org (Backend.DeleteProfile)

func (*Service) GetCRL

func (s *Service) GetCRL(ctx context.Context, req *pb.GetCrlRequest) (*pb.CrlResponse, error)

GetCRL returns the current CRL of an issuer of the org (Backend.GetCRL)

func (*Service) GetCertificate

func (s *Service) GetCertificate(ctx context.Context, req *pb.GetCertificateRequest) (*pb.CertificateResponse, error)

GetCertificate returns a certificate of the org (Backend.GetCertificate)

func (*Service) GetIssuer

func (s *Service) GetIssuer(ctx context.Context, req *pb.GetIssuerRequest) (*pb.Issuer, error)

GetIssuer returns an issuer of the org (Backend.GetIssuer)

func (*Service) GetProfile

func (s *Service) GetProfile(ctx context.Context, req *pb.GetProfileRequest) (*pb.CertProfile, error)

GetProfile returns a profile of the org (Backend.GetProfile)

func (*Service) GetSummary

func (s *Service) GetSummary(ctx context.Context, req *pb.GetSummaryRequest) (*pb.SummaryResponse, error)

GetSummary returns the counts of the org's dashboard (Backend.GetSummary)

func (*Service) ImportIssuer

func (s *Service) ImportIssuer(ctx context.Context, req *pb.ImportIssuerRequest) (*pb.Issuer, error)

ImportIssuer registers an existing issuer and its key (Backend.ImportIssuer)

func (*Service) IsReady

func (s *Service) IsReady() bool

IsReady indicates that the service is ready to serve its end-points

func (*Service) ListCertificates

func (s *Service) ListCertificates(ctx context.Context, req *pb.ListCertificatesRequest) (*pb.CertificatesResponse, error)

ListCertificates returns the certificates of the org (Backend.ListCertificates)

func (*Service) ListIssuers

func (s *Service) ListIssuers(ctx context.Context, req *pb.ListIssuersRequest) (*pb.IssuersResponse, error)

ListIssuers returns the issuers of the org (Backend.ListIssuers)

func (*Service) ListProfiles

func (s *Service) ListProfiles(ctx context.Context, req *pb.ListProfilesRequest) (*pb.ProfilesResponse, error)

ListProfiles returns the profiles of the org (Backend.ListProfiles)

func (*Service) ListRevokedCertificates

func (s *Service) ListRevokedCertificates(ctx context.Context, req *pb.ListRevokedCertificatesRequest) (*pb.RevokedCertificatesResponse, error)

ListRevokedCertificates returns the revoked certificates of the org (Backend.ListRevokedCertificates)

func (*Service) ListRoots

func (s *Service) ListRoots(ctx context.Context, req *pb.ListRootsRequest) (*pb.RootsResponse, error)

ListRoots returns the trust anchors of the org (Backend.ListRoots)

func (*Service) Name

func (s *Service) Name() string

Name returns the service name

func (*Service) PublishCrls

func (s *Service) PublishCrls(ctx context.Context, req *pb.PublishCrlsRequest) (*pb.CrlsResponse, error)

PublishCrls publishes CRLs (Backend.PublishCrls)

func (*Service) RegisterGRPC

func (s *Service) RegisterGRPC(r *grpc.Server)

RegisterGRPC registers gRPC handler

func (*Service) RegisterIssuer

func (s *Service) RegisterIssuer(ctx context.Context, req *pb.RegisterIssuerRequest) (*pb.Issuer, error)

RegisterIssuer creates an issuer of the org (Backend.RegisterIssuer)

func (*Service) RegisterProfile

func (s *Service) RegisterProfile(ctx context.Context, req *pb.RegisterProfileRequest) (*pb.CertProfile, error)

RegisterProfile creates or replaces a profile (Backend.RegisterProfile)

func (*Service) RegisterRoot

func (s *Service) RegisterRoot(ctx context.Context, req *pb.RegisterRootRequest) (*pb.RootCertificate, error)

RegisterRoot registers a trust anchor of the org (Backend.RegisterRoot)

func (*Service) RevokeCertificate

func (s *Service) RevokeCertificate(ctx context.Context, req *pb.RevokeCertificateRequest) (*pb.RevokedCertificateResponse, error)

RevokeCertificate revokes a certificate of the org (Backend.RevokeCertificate)

func (*Service) SignCertificate

func (s *Service) SignCertificate(ctx context.Context, req *pb.SignCertificateRequest) (*pb.CertificateResponse, error)

SignCertificate signs a certificate (Backend.SignCertificate)

func (*Service) SignOCSP

func (s *Service) SignOCSP(ctx context.Context, req *pb.OCSPRequest) (*pb.OCSPResponse, error)

SignOCSP signs an OCSP response (Backend.SignOCSP); the request names the issuer by its key hash and carries no tenant, so it is sent as is

func (*Service) UpdateCertificateLabel

func (s *Service) UpdateCertificateLabel(ctx context.Context, req *pb.UpdateCertificateLabelRequest) (*pb.CertificateResponse, error)

UpdateCertificateLabel updates the label and metadata of a certificate (Backend.UpdateCertificateLabel)

func (*Service) UpdateIssuer

func (s *Service) UpdateIssuer(ctx context.Context, req *pb.UpdateIssuerRequest) (*pb.Issuer, error)

UpdateIssuer changes the settings or the status of an issuer (Backend.UpdateIssuer)

Generated by gomarkdoc