diff options
author | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2020-10-23 18:37:37 +0200 |
---|---|---|
committer | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2020-10-23 18:37:37 +0200 |
commit | 134f7e1cb59b7c1bd4f2eadfebe7f65da1264988 (patch) | |
tree | 0d216c95de64c3f46412a9f87e5dcfe8ad067ea3 /reqres.go | |
parent | 9b38f5a034486c27eaf81062ecdd86a72667e2b0 (diff) |
added start on get-anchors code path
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) { |