code: func WriteCSR(csrDir, name string, csr *x509.CertificateRequest) error {
  	if csr == nil {
  		return errors.New("certificate request cannot be nil when writing to file")
  	}
  
  	csrPath := pathForCSR(csrDir, name)
  	if err := os.MkdirAll(filepath.Dir(csrPath), os.FileMode(0755)); err != nil {
  		return errors.Wrapf(err, "failed to make directory %s", filepath.Dir(csrPath))
  	}
  
  	if err := ioutil.WriteFile(csrPath, EncodeCSRPEM(csr), os.FileMode(0644)); err != nil {
  		return errors.Wrapf(err, "unable to write CSR to file %s", csrPath)
  	}
  
  	return nil
  }
docs: // WriteCSR writes the pem-encoded CSR data to csrPath.
  // The CSR file will be created with file mode 0644.
  // If the CSR file already exists, it will be overwritten.
  // The parent directory of the csrPath will be created as needed with file mode 0755.