diff --git a/src/crypto/x509/x509.go b/src/crypto/x509/x509.go index 9ad3cf23f6..a514c06666 100644 --- a/src/crypto/x509/x509.go +++ b/src/crypto/x509/x509.go @@ -1577,6 +1577,10 @@ func CreateCertificate(rand io.Reader, template, parent *Certificate, pub, priv return nil, errors.New("x509: certificate private key does not implement crypto.Signer") } + if template.SerialNumber == nil { + return nil, errors.New("x509: no SerialNumber given") + } + hashFunc, signatureAlgorithm, err := signingParamsForPublicKey(key.Public(), template.SignatureAlgorithm) if err != nil { return nil, err