code: func WritePKIFiles(t *testing.T, dir string, files PKIFiles) {
  	for filename, body := range files {
  		switch body := body.(type) {
  		case *x509.Certificate:
  			if err := certutil.WriteCert(path.Join(dir, filename), pkiutil.EncodeCertPEM(body)); err != nil {
  				t.Errorf("unable to write certificate to file %q: [%v]", dir, err)
  			}
  		case *rsa.PublicKey:
  			publicKeyBytes, err := pkiutil.EncodePublicKeyPEM(body)
  			if err != nil {
  				t.Errorf("unable to write public key to file %q: [%v]", filename, err)
  			}
  			if err := keyutil.WriteKey(path.Join(dir, filename), publicKeyBytes); err != nil {
  				t.Errorf("unable to write public key to file %q: [%v]", filename, err)
  			}
  		case *rsa.PrivateKey:
  			privateKey, err := keyutil.MarshalPrivateKeyToPEM(body)
  			if err != nil {
  				t.Errorf("unable to write private key to file %q: [%v]", filename, err)
  			}
  			if err := keyutil.WriteKey(path.Join(dir, filename), privateKey); err != nil {
  				t.Errorf("unable to write private key to file %q: [%v]", filename, err)
  			}
  		}
  	}
  }
docs: // WritePKIFiles writes the given files out to the given directory