def export_intermediate_certificate(self, filename=None):
        """
        Export the intermediate certificate. Returned certificate will be in
        string format. If filename is provided, the certificate will also be
        saved to the file specified.
        
        :raises CertificateExportError: error exporting certificate, can occur
            if no intermediate certificate is available.
        :rtype: str or None
        """
        result = self.make_request(
            CertificateExportError,
            raw_result=True,
            resource='intermediate_certificate_export')
            
        if filename is not None:
            save_to_file(filename, result.content)
            return
    
        return result.content