ca

package
v1.5.7 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2025 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	CSRStatusPending  CSRStatus = "pending"
	CSRStatusApproved CSRStatus = "approved"
	CSRStatusDenied   CSRStatus = "denied"

	CSRStatusDescriptionPending  string = "CSR submitted successfully. Await processing."
	CSRStatusDescriptionApproved string = "CSR approved. The certificate is ready for download."
	CSRStatusDescriptionDenied   string = "CSR denied. Please contact the administrator."

	CSRTypeWebhook       CSRType = "webhook"
	CSRTypePrivateServer CSRType = "private_server"
)
View Source
const BASE_URL = "https://ca.sms-gate.app/api/v1"

Variables

This section is empty.

Functions

func IsValidCSRType added in v1.5.5

func IsValidCSRType(t CSRType) bool

IsValidCSRType checks if the given CSR type is valid.

Types

type CSRStatus

type CSRStatus string

func (CSRStatus) Description

func (c CSRStatus) Description() string

Description returns a human-readable description for the given CSR status.

type CSRType added in v1.5.5

type CSRType string

type Client

type Client struct {
	*rest.Client
}

func NewClient

func NewClient(options ...Option) *Client

NewClient creates a new instance of the CA API Client.

func (*Client) GetCSRStatus

func (c *Client) GetCSRStatus(ctx context.Context, requestID string) (GetCSRStatusResponse, error)

GetCSRStatus retrieves the status of a Certificate Signing Request (CSR) from the Certificate Authority (CA) service.

func (*Client) PostCSR

func (c *Client) PostCSR(ctx context.Context, request PostCSRRequest) (PostCSRResponse, error)

PostCSR posts a Certificate Signing Request (CSR) to the Certificate Authority (CA) service.

The service will validate the CSR and respond with a request ID.

The request ID can be used to get the status of the request using the GetCSRStatus method.

type Config

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

func (Config) BaseURL

func (c Config) BaseURL() string

func (Config) Client

func (c Config) Client() *http.Client

type GetCSRStatusResponse

type GetCSRStatusResponse = PostCSRResponse

type Option

type Option func(*Config)

func WithBaseURL

func WithBaseURL(baseURL string) Option

func WithClient

func WithClient(client *http.Client) Option

type PostCSRRequest

type PostCSRRequest struct {
	// Type is the type of the CSR. By default, it is set to "webhook".
	Type CSRType `json:"type,omitempty" default:"webhook"`
	// Content contains the CSR content and is required.
	Content string `json:"content" validate:"required,max=16384,startswith=-----BEGIN CERTIFICATE REQUEST-----"`
	// Metadata includes additional metadata related to the CSR.
	Metadata map[string]string `json:"metadata,omitempty" validate:"dive,keys,max=64,endkeys,max=256"`
}

PostCSRRequest represents a request to post a Certificate Signing Request (CSR).

func (PostCSRRequest) Validate added in v1.5.5

func (c PostCSRRequest) Validate() error

Validate checks if the request is valid.

type PostCSRResponse

type PostCSRResponse struct {
	// RequestID is the ID of the request. Can be used to request status.
	RequestID string `json:"request_id"`
	// Type is the type of the requested certificate.
	Type CSRType `json:"type"`
	// Status is the status of the requested certificate.
	Status CSRStatus `json:"status"`
	// Message is a human-readable description of the status.
	Message string `json:"message"`
	// Certificate is the certificate issued by the CA. This field is only present
	// if the status is `approved`.
	Certificate string `json:"certificate,omitempty"`
}

PostCSRResponse is a response to a request to post a Certificate Signing Request (CSR).

Jump to

Keyboard shortcuts

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