@@ -10,6 +10,7 @@ import (
1010 "crypto/x509"
1111 "crypto/x509/pkix"
1212 "encoding/base64"
13+ "fmt"
1314 "net"
1415 "reflect"
1516 "strings"
@@ -395,6 +396,40 @@ func TestIssue(t *testing.T) {
395396 }
396397}
397398
399+ func TestIssueCertTooBig (t * testing.T ) {
400+ fc := clock .NewFake ()
401+ signer , err := newIssuer (defaultIssuerConfig (), issuerCert , issuerSigner , fc )
402+ if err != nil {
403+ t .Fatalf ("newIssuer: %s" , err )
404+ }
405+ pk , err := ecdsa .GenerateKey (elliptic .P256 (), rand .Reader )
406+ if err != nil {
407+ t .Fatalf ("ecdsa.GenerateKey: %s" , err )
408+ }
409+ var dnsNames []string
410+ for i := 0 ; i < 1000 ; i ++ {
411+ dnsNames = append (dnsNames , fmt .Sprintf ("%d.example.com" , i ))
412+ }
413+ profile := defaultProfile ()
414+ profile .maxCertificateSize = 1000
415+ _ , _ , err = signer .Prepare (profile , & IssuanceRequest {
416+ PublicKey : MarshalablePublicKey {pk .Public ()},
417+ SubjectKeyId : goodSKID ,
418+ Serial : []byte {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 },
419+ DNSNames : dnsNames ,
420+ NotBefore : fc .Now (),
421+ NotAfter : fc .Now ().Add (time .Hour - time .Second ),
422+ IncludeCTPoison : true ,
423+ })
424+ if err == nil {
425+ t .Errorf ("signer.Prepare of big cert: got nil error, want an error" )
426+ }
427+ expected := "linting certificate too big"
428+ if ! strings .Contains (err .Error (), expected ) {
429+ t .Errorf ("signer.Prepare of big cert: got %q, want %q" , err , expected )
430+ }
431+ }
432+
398433func TestIssueDNSNamesOnly (t * testing.T ) {
399434 fc := clock .NewFake ()
400435 signer , err := newIssuer (defaultIssuerConfig (), issuerCert , issuerSigner , fc )
0 commit comments