diff options
Diffstat (limited to 'reqres.go')
-rw-r--r-- | reqres.go | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -11,6 +11,7 @@ import ( "github.com/google/certificate-transparency-go/tls" "github.com/google/certificate-transparency-go/trillian/ctfe" + "github.com/google/certificate-transparency-go/x509" "github.com/google/trillian" ) @@ -50,6 +51,11 @@ type GetProofByHashResponse struct { InclusionProof string `json:"inclusion_proof"` // base64-encoded StItem } +// GetAnchorsResponse +type GetAnchorsResponse struct { + Certificates []string `json:"certificates"` +} + // NewAddEntryRequest parses and sanitizes the JSON-encoded add-entry // parameters from an incoming HTTP post. The resulting AddEntryRequest is // well-formed, but not necessarily trusted (further sanitization is needed). @@ -142,6 +148,14 @@ func NewGetProofByHashResponse(treeSize uint64, inclusionProof *trillian.Proof) }, nil } +func NewGetAnchorsResponse(anchors []*x509.Certificate) GetAnchorsResponse { + certificates := make([]string, 0, len(anchors)) + for _, certificate := range anchors { + certificates = append(certificates, base64.StdEncoding.EncodeToString(certificate.Raw)) + } + return GetAnchorsResponse{Certificates: certificates} +} + // VerifyAddEntryRequest determines whether a well-formed AddEntryRequest should // be inserted into the log. If so, the serialized leaf value is returned. func VerifyAddEntryRequest(a ctfe.CertValidationOpts, r AddEntryRequest) ([]byte, error) { |