cttestsrv

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2019 License: MPL-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IntegrationSrv

type IntegrationSrv struct {
	sync.RWMutex

	// PubKey is the log's public key in base64 encoded format
	PubKey string

	// Addr is the address the *http.Server above is listening on (used for
	// clarifying log messages)
	Addr string
	// contains filtered or unexported fields
}

IntegrationSrv is an instance of a CT test server.

func NewServer

func NewServer(p Personality, logger *log.Logger) (*IntegrationSrv, error)

NewServer creates an IntegrationSrv instance with the given Personality, logging to the given logger. The returned IntegrationSrv instance will not be started until Run() is called.

func (*IntegrationSrv) AddChain

func (is *IntegrationSrv) AddChain(chain []ct.ASN1Cert, precert bool) (*ct.AddChainResponse, error)

AddChain returns a ct.AddChainResponse with an SCT for the provided chain (or an error). The chain will be queued by the testlog's currently active tree. The queue will not be sequenced until integrateBatch is called. The submissions count will be incremented as a result. This function blocks for a variable amount of time based on the latencySchedule and the current latencyItem index. It is safe to call concurrently.

func (*IntegrationSrv) AddMockResponse

func (is *IntegrationSrv) AddMockResponse(
	path string, code int, response interface{})

func (*IntegrationSrv) GetConsistencyProof

func (is *IntegrationSrv) GetConsistencyProof(first, second int64) (*ct.GetSTHConsistencyResponse, error)

GetConsistencyProof returns a GetSTHConsistencyResponse for the currently active testLog tree between the two requested treesizes. This function blocks for a variable amount of time based on the latencySchedule and the current latencyItem index. It is safe to call concurrently.

func (*IntegrationSrv) GetEntries

func (is *IntegrationSrv) GetEntries(start, end int64) (*ct.GetEntriesResponse, error)

GetEntries returns a GetEntriesResponse with the requested entries for the currently active testLog tree. This function blocks for a variable amount of time based on the latencySchedule and the current latencyItem index. It is safe to call concurrently.

func (*IntegrationSrv) GetMockResponse

func (is *IntegrationSrv) GetMockResponse(path string) *mockResponse

func (*IntegrationSrv) GetSTH

func (is *IntegrationSrv) GetSTH() (*ct.GetSTHResponse, error)

GetSTH returns a GetSTHResponse containing either the mockSTH (if not nil) or the STH of the testlog's active tree. The sthFetches count is incremented as a result of this function being called. This function blocks for a variable amount of time based on the latencySchedule and the current latencyItem index. It is safe to call concurrently.

func (*IntegrationSrv) Integrate

func (is *IntegrationSrv) Integrate(count int64) (int, error)

Integrate uses the testLog's currently active tree to sequence up to `count` queued leaves. The number of leaves sequenced is returned. If more than `count` leaves are queued Integrate will need to be called multiple times to fully process the log's queue of unsequenced leaves. It is safe to call concurrently.

func (*IntegrationSrv) RemoveMockResponse

func (is *IntegrationSrv) RemoveMockResponse(path string)

func (*IntegrationSrv) Run

func (is *IntegrationSrv) Run()

Run starts an IntegrationSrv instance by calling ListenAndServe on the integration server's *http.Server in a dedicated goroutine.

func (*IntegrationSrv) STHFetches

func (is *IntegrationSrv) STHFetches() int64

STHFetches returns the number of get-sth requests processed by the server so far. It is safe to call concurrently.

func (*IntegrationSrv) SetSTH

func (is *IntegrationSrv) SetSTH(mockSTH *ct.SignedTreeHead) error

SetSTH allows setting the server's mock STH. It is safe to call concurrently.

func (*IntegrationSrv) Shutdown

func (is *IntegrationSrv) Shutdown()

Shutdown cleanly stops the IntegrationSrv's *http.Server.

func (*IntegrationSrv) Submissions

func (is *IntegrationSrv) Submissions() int64

Submissions returns the number of add-chain/add-pre-chain requests processed so far. It is safe to call concurrently.

func (*IntegrationSrv) SwitchTrees

func (is *IntegrationSrv) SwitchTrees() string

SwitchTrees changes the active testLog tree and returns the DisplayName of the newly activated tree.

type Personality

type Personality struct {
	// Port (and optionally IP) to listen on
	Addr string
	// Base64 encoded private key for signing SCTs
	// Generate your own with:
	// openssl ecparam -name prime256v1 -genkey -outform der -noout | base64 -w 0
	PrivKey string
	// If present, sleep for the given number of seconds before replying. Each
	// request uses the next number in the list, eventually cycling through.
	LatencySchedule []float64

	// If not empty, WindowStart is a datestamp and any certificates with
	// a NotBefore earlier than the WindowStart will be rejected by the log.
	WindowStart string
	// If not empty, WindowEnd is a datestamp and any certificates with
	// a NotAfter later than the WindowEnd will be rejected by the log.
	WindowEnd string
}

Personality describes the configuration & behaviour of a test CT IntegrationSrv

Directories

Path Synopsis
cmd
ct-test-srv
This is a test server that implements the subset of RFC6962 APIs needed by ct-woodpecker.
This is a test server that implements the subset of RFC6962 APIs needed by ct-woodpecker.

Jump to

Keyboard shortcuts

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