code: def format_cert(cert, heads=True):
          
          x509_cert = cert.replace('\x0D', '')
          x509_cert = x509_cert.replace('\r', '')
          x509_cert = x509_cert.replace('\n', '')
          if len(x509_cert) > 0:
              x509_cert = x509_cert.replace('-----BEGIN CERTIFICATE-----', '')
              x509_cert = x509_cert.replace('-----END CERTIFICATE-----', '')
              x509_cert = x509_cert.replace(' ', '')
  
              if heads:
                  x509_cert = "-----BEGIN CERTIFICATE-----\n" + "\n".join(wrap(x509_cert, 64)) + "\n-----END CERTIFICATE-----\n"
  
          return x509_cert
docs: Returns a x509 cert (adding header & footer if required).
  
          :param cert: A x509 unformatted cert
          :type: string
  
          :param heads: True if we want to include head and footer
          :type: boolean
  
          :returns: Formatted cert
          :rtype: string