1
2
3 package integration
4
5 import (
6 "crypto"
7 "crypto/ecdsa"
8 "crypto/elliptic"
9 "crypto/rand"
10 "crypto/x509/pkix"
11 "math/big"
12 "testing"
13 "time"
14
15 "github.com/eggsampler/acme/v3"
16
17 "github.com/letsencrypt/boulder/test"
18 ocsp_helper "github.com/letsencrypt/boulder/test/ocsp/helper"
19 )
20
21
22 type certID struct {
23 HashAlgorithm pkix.AlgorithmIdentifier
24 IssuerNameHash []byte
25 IssuerKeyHash []byte
26 SerialNumber *big.Int
27 }
28
29 func TestARI(t *testing.T) {
30 t.Parallel()
31
32
33 client, err := makeClient("mailto:example@letsencrypt.org")
34 test.AssertNotError(t, err, "creating acme client")
35
36
37 key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
38 test.AssertNotError(t, err, "creating random cert key")
39
40
41
42
43 name := random_domain()
44 ir, err := authAndIssue(client, key, []string{name}, true)
45 test.AssertNotError(t, err, "failed to issue test cert")
46
47 cert := ir.certs[0]
48 issuer, err := ocsp_helper.GetIssuer(cert)
49 test.AssertNotError(t, err, "failed to get issuer cert")
50
51 eri, err := client.GetRenewalInfo(cert, issuer, crypto.SHA256)
52 test.AssertNotError(t, err, "ARI request should have succeeded")
53 test.AssertEquals(t, eri.SuggestedWindow.Start.Sub(time.Now()).Round(time.Hour), 1415*time.Hour)
54 test.AssertEquals(t, eri.SuggestedWindow.End.Sub(time.Now()).Round(time.Hour), 1463*time.Hour)
55 test.AssertEquals(t, eri.RetryAfter.Sub(time.Now()).Round(time.Hour), 6*time.Hour)
56
57
58 err = client.RevokeCertificate(client.Account, cert, client.PrivateKey, 0)
59 test.AssertNotError(t, err, "failed to revoke cert")
60
61 eri, err = client.GetRenewalInfo(cert, issuer, crypto.SHA256)
62 test.AssertNotError(t, err, "ARI request should have succeeded")
63 test.Assert(t, eri.SuggestedWindow.End.Before(time.Now()), "suggested window should end in the past")
64 test.Assert(t, eri.SuggestedWindow.Start.Before(eri.SuggestedWindow.End), "suggested window should start before it ends")
65
66
67
68 err = client.UpdateRenewalInfo(client.Account, cert, issuer, crypto.SHA256, true)
69 test.AssertNotError(t, err, "ARI request should have succeeded")
70
71
72
73
74 name = random_domain()
75 err = ctAddRejectHost(name)
76 test.AssertNotError(t, err, "failed to add ct-test-srv reject host")
77 _, err = authAndIssue(client, key, []string{name}, true)
78 test.AssertError(t, err, "expected error from authAndIssue, was nil")
79
80 cert, err = ctFindRejection([]string{name})
81 test.AssertNotError(t, err, "failed to find rejected precert")
82 issuer, err = ocsp_helper.GetIssuer(cert)
83 test.AssertNotError(t, err, "failed to get issuer cert")
84
85 eri, err = client.GetRenewalInfo(cert, issuer, crypto.SHA256)
86 test.AssertError(t, err, "ARI request should have failed")
87 test.AssertEquals(t, err.(acme.Problem).Status, 404)
88 }
89
View as plain text