code: func genCertificateECDSA(baseDir, name string, template, parent *x509.Certificate, pub *ecdsa.PublicKey,
  	priv interface{}) (*x509.Certificate, error) {
  
  	//create the x509 public cert
  	certBytes, err := x509.CreateCertificate(rand.Reader, template, parent, pub, priv)
  	if err != nil {
  		return nil, err
  	}
  
  	//write cert out to file
  	fileName := filepath.Join(baseDir, name+"-cert.pem")
  	certFile, err := os.Create(fileName)
  	if err != nil {
  		return nil, err
  	}
  	//pem encode the cert
  	err = pem.Encode(certFile, &pem.Block{Type: "CERTIFICATE", Bytes: certBytes})
  	certFile.Close()
  	if err != nil {
  		return nil, err
  	}
  
  	x509Cert, err := x509.ParseCertificate(certBytes)
  	if err != nil {
  		return nil, err
  	}
  	return x509Cert, nil
  }
docs: // generate a signed X509 certificate using ECDSA