1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
17 func TestCertificateTransparency(t *testing.T) {
18 // Test that we can verify actual Certificate Transparency proofs.
19 // (The other tests check that we can verify our own proofs;
20 // this is a test that the two are compatible.)
23 t.Skip("skipping in -short mode")
27 httpGET(t, "http://ct.googleapis.com/logs/argon2020/ct/v1/get-sth", &root)
30 httpGET(t, "http://ct.googleapis.com/logs/argon2020/ct/v1/get-entries?start=10000&end=10000", &leaf)
31 hash := RecordHash(leaf.Entries[0].Data)
34 httpGET(t, "http://ct.googleapis.com/logs/argon2020/ct/v1/get-proof-by-hash?tree_size="+fmt.Sprint(root.Size)+"&hash="+url.QueryEscape(hash.String()), &rp)
36 err := CheckRecord(rp.Proof, root.Size, root.Hash, 10000, hash)
42 httpGET(t, "http://ct.googleapis.com/logs/argon2020/ct/v1/get-sth-consistency?first=3654490&second="+fmt.Sprint(root.Size), &tp)
44 oh, _ := ParseHash("AuIZ5V6sDUj1vn3Y1K85oOaQ7y+FJJKtyRTl1edIKBQ=")
45 err = CheckTree(tp.Proof, root.Size, root.Hash, 3654490, oh)
52 Size int64 `json:"tree_size"`
53 Hash Hash `json:"sha256_root_hash"`
56 type ctEntries struct {
61 Data []byte `json:"leaf_input"`
64 type ctRecordProof struct {
65 Index int64 `json:"leaf_index"`
66 Proof RecordProof `json:"audit_path"`
69 type ctTreeProof struct {
70 Proof TreeProof `json:"consistency"`
73 func httpGET(t *testing.T, url string, targ interface{}) {
74 if testing.Verbose() {
78 resp, err := http.Get(url)
82 defer resp.Body.Close()
83 data, err := ioutil.ReadAll(resp.Body)
87 if testing.Verbose() {
90 err = json.Unmarshal(data, targ)