title: Convert python x509 Signing Request object (x509.CertificateSigningRequest) object to bytes
body: <p>I need to convert an x509.CertificateSigningRequest object to bytes</p>
  <p>Here is the method that returns the x509.CertificateSigningRequest object</p>
  <pre class="lang-py prettyprint-override"><code>def csr(private_key: rsa.RSAPrivateKey) -&gt; x509.CertificateSigningRequest:
      b = x509.CertificateSigningRequestBuilder()
      req = b.subject_name(x509.Name([
          x509.NameAttribute(NameOID.COUNTRY_NAME, u&quot;US&quot;),
          x509.NameAttribute(NameOID.STATE_OR_PROVINCE_NAME, u&quot;CA&quot;),
          x509.NameAttribute(NameOID.LOCALITY_NAME, u&quot;San Francisco&quot;),
          x509.NameAttribute(NameOID.ORGANIZATION_NAME, u&quot;Command1&quot;),
          x509.NameAttribute(NameOID.COMMON_NAME, u&quot;Commandment&quot;),
      ])).sign(private_key, hashes.SHA256(), default_backend())
  
      return req 
  </code></pre>
  <p>Does someone know how to do this?
  Thanks in advance</p>