Skip to content

Commit beeced8

Browse files
committed
Allowing CSR to take CRL url as input which can then be used on a certificate
1 parent efd6a76 commit beeced8

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

csr/csr.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ type CertificateRequest struct {
139139
CA *CAConfig `json:"ca,omitempty" yaml:"ca,omitempty"`
140140
SerialNumber string `json:"serialnumber,omitempty" yaml:"serialnumber,omitempty"`
141141
Extensions []pkix.Extension `json:"extensions,omitempty" yaml:"extensions,omitempty"`
142+
CRL string `json:"crl_url,omitempty" yaml:"crl_url,omitempty"`
142143
}
143144

144145
// New returns a new, empty CertificateRequest with a

initca/initca.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ func New(req *csr.CertificateRequest) (cert, csrPEM, key []byte, err error) {
6969
}
7070
}
7171

72+
if req.CRL != "" {
73+
policy.Default.CRL = req.CRL
74+
}
75+
7276
g := &csr.Generator{Validator: validator}
7377
csrPEM, key, err = g.ProcessRequest(req)
7478
if err != nil {

initca/initca_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ var invalidCryptoParams = []csr.KeyRequest{
6464
func TestInitCA(t *testing.T) {
6565
var req *csr.CertificateRequest
6666
hostname := "cloudflare.com"
67+
crl := "http://crl.cloudflare.com/655c6a9b-01c6-4eea-bf21-be690cc315e0.crl" //cert_uuid.crl
6768
for _, param := range validKeyParams {
6869
for _, caconfig := range validCAConfigs {
6970
req = &csr.CertificateRequest{
@@ -80,6 +81,7 @@ func TestInitCA(t *testing.T) {
8081
Hosts: []string{hostname, "www." + hostname},
8182
KeyRequest: &param,
8283
CA: &caconfig,
84+
CRL: crl,
8385
}
8486
certBytes, _, keyBytes, err := New(req)
8587
if err != nil {
@@ -94,6 +96,18 @@ func TestInitCA(t *testing.T) {
9496
t.Fatal("InitCA cert parsing failed:", err)
9597
}
9698

99+
// Verify if the CRL is set
100+
crlSet := false
101+
for _, certCrl := range cert.CRLDistributionPoints {
102+
if certCrl == crl {
103+
crlSet = true
104+
break
105+
}
106+
}
107+
if !crlSet {
108+
t.Fatal("Missing CRL on certificate")
109+
}
110+
97111
// Verify key parameters.
98112
switch req.KeyRequest.Algo() {
99113
case "rsa":
@@ -126,14 +140,15 @@ func TestInitCA(t *testing.T) {
126140
}
127141
}
128142

129-
// Replace the default CAPolicy with a test (short expiry) version.
143+
// Replace the default CAPolicy with a test (short expiry) version and add a crl
130144
CAPolicy = func() *config.Signing {
131145
return &config.Signing{
132146
Default: &config.SigningProfile{
133147
Usage: []string{"cert sign", "crl sign"},
134148
ExpiryString: "300s",
135149
Expiry: 300 * time.Second,
136150
CAConstraint: config.CAConstraint{IsCA: true},
151+
CRL: crl,
137152
},
138153
}
139154
}

0 commit comments

Comments
 (0)