public function encryptAccountPassword($x509File, $desktopPassword)
    {
        $directory = sys_get_temp_dir();
        $filePrefix = "azure";
        $pkcs7In = $directory . "/" . $filePrefix . "_in.pkcs7";
        $pkcs7Out = $directory . "/" . $filePrefix . "_out.pkcs7";
        $certificate = openssl_x509_read(file_get_contents($x509File));
        
        file_put_contents($pkcs7In, $desktopPassword);
        $ret = openssl_pkcs7_encrypt($pkcs7In, $pkcs7Out, $certificate, array());
        
        if (! $ret) {
            throw new \RuntimeException("Encrypting Password failed.");
        }
        
        $parts = explode("\n\n", file_get_contents($pkcs7Out));
        $body = str_replace("\n", "", $parts[1]);
        
        unlink($pkcs7In);
        unlink($pkcs7Out);
        
        return $body;
    }