Now that we have a private key, we can go ahead and generate our certificate. We have already seen how easy this is to create with openssl, and it is just as easy in Go:
125 func generateX509Certificate( 126 key *rsa.PrivateKey, 127 template *x509.Certificate, 128 duration time.Duration, 129 parentKey *rsa.PrivateKey, 130 parentCert *x509.Certificate) []byte { 131 132 notBefore := time.Now() 133 notAfter := notBefore.Add(duration) 134 135 template.NotBefore = notBefore 136 template.NotAfter = notAfter 137 138 serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) 139 serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) 140 if err != nil { 141 panic(fmt.Errorf("failed to generate serial number: %s", ...