def export(self, body, chain, key, options, **kwargs):
        """
        Generates a PKCS#12 archive.

        :param key:
        :param chain:
        :param body:
        :param options:
        :param kwargs:
        """
        if self.get_option("passphrase", options):
            passphrase = self.get_option("passphrase", options)
        else:
            passphrase = get_psuedo_random_string()

        if self.get_option("alias", options):
            alias = self.get_option("alias", options)
        else:
            alias = common_name(parse_certificate(body))

        type = self.get_option("type", options)

        with mktemppath() as output_tmp:
            if type == "PKCS12 (.p12)":
                if not key:
                    raise Exception(f"Private Key required by {type}")

                create_pkcs12(body, chain, output_tmp, key, alias, passphrase)
                extension = "p12"
            elif type == "legacy PKCS12 (.p12)":
                if not key:
                    raise Exception(f"Private Key required by {type}")

                create_pkcs12(body, chain, output_tmp, key, alias, passphrase, legacy=True)
                extension = "p12"

            else:
                raise Exception(f"Unable to export, unsupported type: {type}")

            with open(output_tmp, "rb") as f:
                raw = f.read()

        return extension, passphrase, raw

        Generates a PKCS#12 archive.

        :param key:
        :param chain:
        :param body:
        :param options:
        :param kwargs:
        
lemur/plugins/lemur_openssl/plugin.py