package client
import "github.com/google/monologue/client"
Package client provides a Certificate Transparency (CT) Log Client that prioritizes preserving and returning as much information about each http request that is made, and detailed descriptions of any errors that occur along the way.
Index ¶
- type BodyReadError
- type GetError
- type HTTPData
- type HTTPStatusError
- type JSONParseError
- type LogClient
- func New(logURL string, hc *http.Client) *LogClient
- func (lc *LogClient) AddChain(chain []*x509.Certificate) (*ct.SignedCertificateTimestamp, *HTTPData, error)
- func (lc *LogClient) AddPreChain(chain []*x509.Certificate) (*ct.SignedCertificateTimestamp, *HTTPData, error)
- func (lc *LogClient) GetProofByHash(hash []byte, treeSize uint64) (*ct.GetProofByHashResponse, *HTTPData, error)
- func (lc *LogClient) GetRoots() ([]*x509.Certificate, *HTTPData, error)
- func (lc *LogClient) GetSTH() (*ct.SignedTreeHead, *HTTPData, error)
- type NilResponseError
- type PostError
- type ResponseToStructError
- type Timing
Types ¶
type BodyReadError ¶
BodyReadError for if reading the body of an http.Response fails.
func (*BodyReadError) Error ¶
func (e *BodyReadError) Error() string
type GetError ¶
GetError for if http.Client.Get() fails.
func (*GetError) Error ¶
type HTTPData ¶
HTTPData contains information about an HTTP request that was made.
type HTTPStatusError ¶
type HTTPStatusError struct { StatusCode int }
HTTPStatusError for if the status code of an HTTP response is not 200.
func (*HTTPStatusError) Error ¶
func (e *HTTPStatusError) Error() string
type JSONParseError ¶
JSONParseError for if JSON fails to parse.
func (*JSONParseError) Error ¶
func (e *JSONParseError) Error() string
type LogClient ¶
type LogClient struct {
// contains filtered or unexported fields
}
LogClient is a client for a specific CT Log.
Most of the LogClient methods return HTTPData structs and errors.
A returned HTTPData struct contains:
- Timing: The time it took for the LogClient's HTTP client to send the request and receive a response.
- Response: The http.Response returned by the LogClient's HTTP client, with http.Response.Body already read and closed.
- Body: The body of the response received, read from the Body field in the http.Response returned by the LogClient's HTTP client.
This HTTPData struct will always be returned containing at least the timing of the request, even in the case where an error is returned too.
If an error is returned it could be any of the following types, in addition to any error types specified in the documentation specific to that method. The type of error that is returned influences what the HTTPData struct returned will contain:
- GetError
- HTTPData will contain only the timing of the request.
- PostError
- HTTPData will contain only the timing of the request.
- NilResponseError
- HTTPData will contain only the timing of the request.
- BodyReadError
- HTTPData will contain the timing of the request and the received response.
- HTTPStatusError
- HTTPData will contain the timing of the request, the received response, and the body of the response.
- JSONParseError
- HTTPData will contain the timing of the request, the received response, and the body of the response.
func New ¶
New creates a new LogClient for monitoring the CT Log served at logURL.
func (*LogClient) AddChain ¶
func (lc *LogClient) AddChain(chain []*x509.Certificate) (*ct.SignedCertificateTimestamp, *HTTPData, error)
AddChain performs an add-chain request, posting the provided certificate chain to the CT Log hosted at LogClient.url. The first certificate in the chain must be the end-entity certificate, with the second chaining to the first and so on to the last, which should either be the root certificate or a certificate that chains to a root certificate that is accepted by the Log. Returned is:
- a populated ct.SignedCertificateTimestamp, if no error is returned.
- an HTTPData struct (may be non-nil even when err != nil, see above).
- an error, which could be an error from the Go standard library, any of the error types listed in the LogClient documentation (see above), or a ResponseToStructError.
func (*LogClient) AddPreChain ¶
func (lc *LogClient) AddPreChain(chain []*x509.Certificate) (*ct.SignedCertificateTimestamp, *HTTPData, error)
AddPreChain performs an add-pre-chain request, posting the provided certificate chain to the CT Log hosted at LogClient.url. The first certificate in the chain must be the end-entity pre-certificate, with the second chaining to the first and so on to the last, which should either be the root certificate or a certificate that chains to a root certificate that is accepted by the Log. Returned is:
- a populated ct.SignedCertificateTimestamp, if no error is returned.
- an HTTPData struct (may be non-nil even when err != nil, see above).
- an error, which could be an error from the Go standard library, any of the error types listed in the LogClient documentation (see above), or a ResponseToStructError.
func (*LogClient) GetProofByHash ¶
func (lc *LogClient) GetProofByHash(hash []byte, treeSize uint64) (*ct.GetProofByHashResponse, *HTTPData, error)
GetProofByHash performs a get-proof-by-hash request, with parameters hash and treeSize. Returned is:
- a GetProofByHashResponse struct, if no error is returned.
- the HTTPData struct returned by GetAndParse() (see above).
- an error, which could be any of the error types returned by GetAndParse().
func (*LogClient) GetRoots ¶
func (lc *LogClient) GetRoots() ([]*x509.Certificate, *HTTPData, error)
GetRoots performs a get-roots request. Returned is:
- a list of certificates, if no error is returned.
- the HTTPData struct returned by GetAndParse() (see above).
- an error, which could be any of the error types returned by GetAndParse(), or a ResponseToStructError.
func (*LogClient) GetSTH ¶
func (lc *LogClient) GetSTH() (*ct.SignedTreeHead, *HTTPData, error)
GetSTH performs a get-sth request. Returned is:
- a populated ct.SignedTreeHead, if no error is returned.
- an HTTPData struct (see above).
- an error, which could be any of the error types listed in the LogClient documentation (see above), or a ResponseToStructError.
type NilResponseError ¶
type NilResponseError struct { URL string }
NilResponseError for if http.Client.Get() returns a nil response, but no error.
func (*NilResponseError) Error ¶
func (e *NilResponseError) Error() string
type PostError ¶
PostError for if http.Client.Post() fails.
func (*PostError) Error ¶
func (*PostError) VerboseError ¶
type ResponseToStructError ¶
ResponseToStructError for if conversion from response type to ct type fails.
func (*ResponseToStructError) Error ¶
func (e *ResponseToStructError) Error() string
type Timing ¶
Timing represents an interval of time. It can be used to represent when an event started and ended.
Source Files ¶
- Version
- v0.0.0-20230315160450-1dc62842925e (latest)
- Published
- Mar 15, 2023
- Platform
- linux/amd64
- Imports
- 13 packages
- Last checked
- 1 day ago –
Tools for package owners.