def pem(self):
        """
        Serialize in PEM format
        """
        bio = Membio()
        if not libcrypto.PEM_write_bio_CMS(bio.bio, self.ptr):
            raise CMSError("writing CMS to PEM")
        return str(bio)