issuance: add CRLDP to certs

Gated by nonzero crlShards config field.
diff --git a/issuance/cert.go b/issuance/cert.go
index 0c97b1b..9800a4f 100644
--- a/issuance/cert.go
+++ b/issuance/cert.go
@@ -13,6 +13,7 @@
 	"errors"
 	"fmt"
 	"math/big"
+	mathrand "math/rand"
 	"sync"
 	"time"
 
@@ -383,6 +384,12 @@
 		template.ExtraExtensions = append(template.ExtraExtensions, mustStapleExt)
 	}
 
+	if i.crlShards > 0 {
+		template.CRLDistributionPoints = []string{
+			i.crlURL(mathrand.Intn(i.crlShards)),
+		}
+	}
+
 	// check that the tbsCertificate is properly formed by signing it
 	// with a throwaway key and then linting it using zlint
 	lintCertBytes, err := i.Linter.Check(template, req.PublicKey.PublicKey, prof.lints)
diff --git a/issuance/crl.go b/issuance/crl.go
index 48fc54e..223639d 100644
--- a/issuance/crl.go
+++ b/issuance/crl.go
@@ -59,6 +59,10 @@
 	Entries []x509.RevocationListEntry
 }
 
+func (i *Issuer) crlURL(shard int) string {
+	return fmt.Sprintf("%s%d.crl", i.crlURLBase, shard)
+}
+
 func (i *Issuer) IssueCRL(prof *CRLProfile, req *CRLRequest) ([]byte, error) {
 	backdatedBy := i.clk.Now().Sub(req.ThisUpdate)
 	if backdatedBy > prof.maxBackdate {
@@ -82,7 +86,7 @@
 	// Concat the base with the shard directly, since we require that the base
 	// end with a single trailing slash.
 	idp, err := idp.MakeUserCertsExt([]string{
-		fmt.Sprintf("%s%d.crl", i.crlURLBase, req.Shard),
+		i.crlURL(int(req.Shard)),
 	})
 	if err != nil {
 		return nil, fmt.Errorf("creating IDP extension: %w", err)
diff --git a/issuance/issuer.go b/issuance/issuer.go
index 6917f07..a08fa19 100644
--- a/issuance/issuer.go
+++ b/issuance/issuer.go
@@ -164,6 +164,13 @@
 	OCSPURL    string `validate:"required,url"`
 	CRLURLBase string `validate:"omitempty,url,startswith=http://,endswith=/"`
 
+	// Number of CRL shards.
+	// If this is zero, no CRLDP will be added to issued certs.
+	// If this is nonzero, a single CRLDP will be added to issued certs, based
+	// on CRLURLBase. A random shard will be selected between 1 and CRLShards,
+	// inclusive.
+	CRLShards int
+
 	Location IssuerLoc
 }
 
@@ -204,9 +211,11 @@
 	// certificates.
 	ocspURL string
 	// Used to set the Issuing Distribution Point extension in issued CRLs
-	// *and* (eventually) the CRL Distribution Point extension in issued certs.
+	// and the CRL Distribution Point extension in issued certs.
 	crlURLBase string
 
+	crlShards int
+
 	clk clock.Clock
 }
 
@@ -276,6 +285,7 @@
 		issuerURL:  config.IssuerURL,
 		ocspURL:    config.OCSPURL,
 		crlURLBase: config.CRLURLBase,
+		crlShards:  config.CRLShards,
 		clk:        clk,
 	}
 	return i, nil
diff --git a/test/config-next/ca.json b/test/config-next/ca.json
index 37f69f6..ead8b5d 100644
--- a/test/config-next/ca.json
+++ b/test/config-next/ca.json
@@ -78,6 +78,7 @@
 					"issuerURL": "http://ca.example.org:4502/int-ecdsa-a",
 					"ocspURL": "http://ca.example.org:4002/",
 					"crlURLBase": "http://ca.example.org:4501/ecdsa-a/",
+					"crlShards": 2,
 					"location": {
 						"configFile": "test/certs/webpki/int-ecdsa-a.pkcs11.json",
 						"certFile": "test/certs/webpki/int-ecdsa-a.cert.pem",
@@ -89,6 +90,7 @@
 					"issuerURL": "http://ca.example.org:4502/int-ecdsa-b",
 					"ocspURL": "http://ca.example.org:4002/",
 					"crlURLBase": "http://ca.example.org:4501/ecdsa-b/",
+					"crlShards": 300,
 					"location": {
 						"configFile": "test/certs/webpki/int-ecdsa-b.pkcs11.json",
 						"certFile": "test/certs/webpki/int-ecdsa-b.cert.pem",
@@ -100,6 +102,7 @@
 					"issuerURL": "http://ca.example.org:4502/int-ecdsa-c",
 					"ocspURL": "http://ca.example.org:4002/",
 					"crlURLBase": "http://ca.example.org:4501/ecdsa-c/",
+					"crlShards": 2,
 					"location": {
 						"configFile": "test/certs/webpki/int-ecdsa-c.pkcs11.json",
 						"certFile": "test/certs/webpki/int-ecdsa-c.cert.pem",
@@ -111,6 +114,7 @@
 					"issuerURL": "http://ca.example.org:4502/int-rsa-a",
 					"ocspURL": "http://ca.example.org:4002/",
 					"crlURLBase": "http://ca.example.org:4501/rsa-a/",
+					"crlShards": 2,
 					"location": {
 						"configFile": "test/certs/webpki/int-rsa-a.pkcs11.json",
 						"certFile": "test/certs/webpki/int-rsa-a.cert.pem",
@@ -122,6 +126,7 @@
 					"issuerURL": "http://ca.example.org:4502/int-rsa-b",
 					"ocspURL": "http://ca.example.org:4002/",
 					"crlURLBase": "http://ca.example.org:4501/rsa-b/",
+					"crlShards": 2,
 					"location": {
 						"configFile": "test/certs/webpki/int-rsa-b.pkcs11.json",
 						"certFile": "test/certs/webpki/int-rsa-b.cert.pem",
@@ -133,6 +138,7 @@
 					"issuerURL": "http://ca.example.org:4502/int-rsa-c",
 					"ocspURL": "http://ca.example.org:4002/",
 					"crlURLBase": "http://ca.example.org:4501/rsa-c/",
+					"crlShards": 2,
 					"location": {
 						"configFile": "test/certs/webpki/int-rsa-c.pkcs11.json",
 						"certFile": "test/certs/webpki/int-rsa-c.cert.pem",