TBR: veyron/services/identity: Generate the cert in the correct tmpdir.

Change-Id: Id99a8ffc155abf9d85a016f3445c9d6cc3ac8a97
diff --git a/services/identity/util/certs.go b/services/identity/util/certs.go
index 646ac35..ca57cca 100644
--- a/services/identity/util/certs.go
+++ b/services/identity/util/certs.go
@@ -13,15 +13,16 @@
 // duration and writes them to cert.pem and key.pem in tmpdir.  It returns the
 // locations of the files, or an error if one is encountered.
 func WriteCertAndKey(host string, duration time.Duration) (string, string, error) {
-	tmpDir := os.TempDir()
 	listCmd := exec.Command("go", "list", "-f", "{{.Dir}}", "crypto/tls")
-	listCmd.Dir = tmpDir
 	output, err := listCmd.Output()
 	if err != nil {
 		return "", "", fmt.Errorf("%s failed: %v", strings.Join(listCmd.Args, " "), err)
 	}
+	tmpDir := os.TempDir()
 	generateCertFile := filepath.Join(strings.TrimSpace(string(output)), "generate_cert.go")
-	if err := exec.Command("go", "run", generateCertFile, "--host", host, "--duration", duration.String()).Run(); err != nil {
+	generateCertCmd := exec.Command("go", "run", generateCertFile, "--host", host, "--duration", duration.String())
+	generateCertCmd.Dir = tmpDir
+	if err := generateCertCmd.Run(); err != nil {
 		return "", "", fmt.Errorf("Could not generate key and cert: %v", err)
 	}
 	return filepath.Join(tmpDir, "cert.pem"), filepath.Join(tmpDir, "key.pem"), nil