ssllabs

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package ssllabs is the library behind the ssllabs command line: the HTTP client, request shaping, and the typed data models for the SSL Labs API (api.ssllabs.com/api/v3).

The Client sets a real User-Agent, paces requests at 2 s intervals (SSL Labs enforces concurrency limits), and retries transient 429 / 5xx failures. Build your endpoint calls on top of Get.

Index

Constants

View Source
const BaseURL = "https://api.ssllabs.com/api/v3"

BaseURL is the root every API request is built from.

View Source
const DefaultUserAgent = "ssllabs-cli/dev (+https://github.com/tamnd/ssllabs-cli)"

DefaultUserAgent identifies the client to SSL Labs.

View Source
const Host = "api.ssllabs.com"

Host is the domain this driver claims in the URI scheme.

View Source
const SiteURL = "https://www.ssllabs.com/ssltest/analyze.html"

SiteURL is the human-readable SSL Labs test page used by Locate.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assessment

type Assessment struct {
	Host      string     `kit:"id" json:"host"`
	Port      int        `json:"port"`
	Status    string     `json:"status"`
	StartTime int64      `json:"start_time"`
	Endpoints []Endpoint `json:"endpoints"`
}

Assessment is the top-level result from /analyze.

type Client

type Client struct {
	HTTP      *http.Client
	UserAgent string
	// Rate is the minimum gap between requests.
	Rate    time.Duration
	Retries int
	// contains filtered or unexported fields
}

Client talks to the SSL Labs API over HTTPS.

func NewClient

func NewClient() *Client

NewClient returns a Client with the default configuration.

func (*Client) Analyze

func (c *Client) Analyze(ctx context.Context, host string, fromCache bool) (*Assessment, error)

Analyze calls /analyze for the given hostname. When fromCache is true it passes startNew=off&fromCache=on&maxAge=12. When fromCache is false it passes startNew=on.

func (*Client) Get

func (c *Client) Get(ctx context.Context, rawURL string) ([]byte, error)

Get fetches url and returns the response body. It paces and retries according to the client's settings.

func (*Client) Info

func (c *Client) Info(ctx context.Context) (*Info, error)

Info calls /info and returns API metadata.

type Config

type Config struct {
	UserAgent string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
}

Config carries tunable client parameters.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the recommended defaults.

type Domain

type Domain struct{}

Domain is the SSL Labs driver.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify turns a hostname or ssllabs.com URL into (type, id). "google.com" or "google.com:443" → ("host", "google.com")

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the matched hostnames, and the binary identity.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate returns the human-readable SSL Labs test URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation.

type Endpoint

type Endpoint struct {
	IPAddress string `json:"ip_address"`
	Grade     string `json:"grade"`
	Status    string `json:"status"`
	Duration  int    `json:"duration_ms"`
	Progress  int    `json:"progress"`
}

Endpoint is one IP address inside an Assessment.

type Info

type Info struct {
	Version            string `kit:"id" json:"version"`
	CriteriaVersion    string `json:"criteria_version"`
	MaxAssessments     int    `json:"max_assessments"`
	CurrentAssessments int    `json:"current_assessments"`
}

Info holds metadata returned by the SSL Labs /info endpoint.

Jump to

Keyboard shortcuts

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