public function export($directory, $filePrefix, $keyPassword, $overwrite = false)
    {
        if (! is_writeable($directory)) {
            throw new \RuntimeException("Key Export directory is not writable: " . $directory);
        }
        
        $pkcs12File = $directory . "/" . $filePrefix . ".pfx";
        $x509File = $directory . "/" . $filePrefix . ".cer";
        
        if (! $overwrite && file_exists($pkcs12File)) {
            throw new \RuntimeException("PKCS12 File at " . $pkcs12File . " already exists and is not overwritten.");
        }
        
        if (! $overwrite && file_exists($x509File)) {
            throw new \RuntimeException("X509 Certificate File at " . $x509File . " already exists and is not overwritten.");
        }
        
        $args = array(
            'friendly_name' => 'AzureDistributionBundle for Symfony Tools'
        );
        openssl_pkcs12_export_to_file($this->certificate, $pkcs12File, $this->privKey, $keyPassword, $args);
        openssl_x509_export_to_file($this->certificate, $x509File, true);
        
        return $x509File;
    }