crypto/x509: return error for missing SerialNumber.
crypto/x509: return error for missing SerialNumber.

If the SerialNumber is nil in the template then the resulting panic is
rather deep in encoding/asn1 and it's not obvious what went wrong.

This change tests and returns a more helpful error in this case.

Fixes #16603.

Change-Id: Ib30d652555191eb78f705dff8d909e4b5808f9ca
Reviewed-on: https://go-review.googlesource.com/27238
Reviewed-by: Brad Fitzpatrick <ae9783c0b0efc69cd85ab025ddd17aa44cdc4aa5@golang.org>

golang/go,Cofyc/go,josharian/go,Cofyc/go,linux-on-ibm-z/go,josharian/go,linux-on-ibm-z/go,ImJasonH/go,momchil-velikov/go,ImJasonH/go,cloudflare/go,josharian/go,ImJasonH/go,akutz/go,cloudflare/go,suncycheng/go,derekmarcotte/go,goodlang/good,momchil-velikov/go,linux-on-ibm-z/go,CAFxX/go,derekmarcotte/go,suncycheng/go,linux-on-ibm-z/go,momchil-velikov/go,polyverse-security/go,polyverse-security/go,nawawi/go,momchil-velikov/go,Cofyc/go,codestation/go,CAFxX/go,akutz/go,linux-on-ibm-z/go,ImJasonH/go,linux-on-ibm-z/go,cloudflare/go,CAFxX/go,cloudflare/go,CAFxX/go,derekmarcotte/go,CAFxX/go,nawawi/go,suncycheng/go,derekmarcotte/go,vsekhar/elastic-go,codestation/go,goodlang/good,akutz/go,vsekhar/elastic-go,Cofyc/go,nawawi/go,ImJasonH/go,golang/go,josharian/go,derekmarcotte/go,suncycheng/go,golang/go,Cofyc/go,suncycheng/go,derekmarcotte/go,CAFxX/go,Cofyc/go,vsekhar/elastic-go,polyverse-security/go,nawawi/go,ImJasonH/go,goodlang/good,linux-on-ibm-z/go,golang/go,derekmarcotte/go,cloudflare/go,ImJasonH/go,momchil-velikov/go,Cofyc/go,suncycheng/go,goodlang/good,vsekhar/elastic-go,momchil-velikov/go,akutz/go,vsekhar/elastic-go,momchil-velikov/go,cloudflare/go,akutz/go,CAFxX/go,nawawi/go,polyverse-security/go,golang/go,golang/go,codestation/go,akutz/go,derekmarcotte/go,cloudflare/go,codestation/go,polyverse-security/go,golang/go,golang/go,vsekhar/elastic-go,nawawi/go,goodlang/good,goodlang/good,codestation/go,codestation/go,vsekhar/elastic-go,codestation/go,linux-on-ibm-z/go,suncycheng/go,Cofyc/go,josharian/go,cloudflare/go,josharian/go,polyverse-security/go,goodlang/good,momchil-velikov/go,akutz/go,ImJasonH/go,akutz/go,vsekhar/elastic-go,codestation/go,suncycheng/go,polyverse-security/go,josharian/go,polyverse-security/go,christopher-henderson/Go,nawawi/go,CAFxX/go,nawawi/go,josharian/go,goodlang/good