code: def export_to_pem(self, private_key=False, password=False):
          
          e = serialization.Encoding.PEM
          if private_key:
              if not self.has_private:
                  raise InvalidJWKType("No private key available")
              f = serialization.PrivateFormat.PKCS8
              if password is None:
                  a = serialization.NoEncryption()
              elif isinstance(password, bytes):
                  a = serialization.BestAvailableEncryption(password)
              elif password is False:
                  raise ValueError("The password must be None or a bytes string")
              else:
                  raise TypeError("The password string must be bytes")
              return self._get_private_key().private_bytes(
                  encoding=e, format=f, encryption_algorithm=a)
          else:
              if not self.has_public:
                  raise InvalidJWKType("No public key available")
              f = serialization.PublicFormat.SubjectPublicKeyInfo
              return self._get_public_key().public_bytes(encoding=e, format=f)
docs: Exports keys to a data buffer suitable to be stored as a PEM file.
          Either the public or the private key can be exported to a PEM file.
          For private keys the PKCS#8 format is used. If a password is provided
          the best encryption method available as determined by the cryptography
          module is used to wrap the key.
  
          :param private_key: Whether the private key should be exported.
           Defaults to `False` which means the public key is exported by default.
          :param password(bytes): A password for wrapping the private key.
           Defaults to False which will cause the operation to fail. To avoid
           encryption the user must explicitly pass None, otherwise the user
           needs to provide a password in a bytes buffer.