code: func ParseCertificatePEM(certPEM []byte) (*x509.Certificate, error) {
  	certPEM = bytes.TrimSpace(certPEM)
  	cert, rest, err := ParseOneCertificateFromPEM(certPEM)
  	if err != nil {
  		// Log the actual parsing error but throw a default parse error message.
  		log.Debugf("Certificate parsing error: %v", err)
  		return nil, cferr.New(cferr.CertificateError, cferr.ParseFailed)
  	} else if cert == nil {
  		return nil, cferr.New(cferr.CertificateError, cferr.DecodeFailed)
  	} else if len(rest) > 0 {
  		return nil, cferr.Wrap(cferr.CertificateError, cferr.ParseFailed, errors.New("the PEM file should contain only one object"))
  	} else if len(cert) > 1 {
  		return nil, cferr.Wrap(cferr.CertificateError, cferr.ParseFailed, errors.New("the PKCS7 object in the PEM file should contain only one certificate"))
  	}
  	return cert[0], nil
  }
docs: // ParseCertificatePEM parses and returns a PEM-encoded certificate,
  // can handle PEM encoded PKCS #7 structures.