def create_pkcs12(cert, chain, p12_tmp, key, alias, passphrase, legacy: bool = False):
    """
    Creates a pkcs12 formated file.
    :param cert:
    :param chain:
    :param p12_tmp:
    :param key:
    :param alias:
    :param passphrase:
    :param legacy: should legacy insecure encryption be used (for support with ancient Java versions)
    """
    assert isinstance(cert, str)
    if chain is not None:
        assert isinstance(chain, str)
    assert isinstance(key, str)

    with mktempfile() as key_tmp:
        with open(key_tmp, "w") as f:
            f.write(key)

        # Create PKCS12 keystore from private key and public certificate
        with mktempfile() as cert_tmp:
            with open(cert_tmp, "w") as f:
                if chain:
                    f.writelines([cert.strip() + "\n", chain.strip() + "\n"])
                else:
                    f.writelines([cert.strip() + "\n"])
            cmd = [
                "openssl",
                "pkcs12",
                "-export",
                "-name",
                alias,
                "-in",
                cert_tmp,
                "-inkey",
                key_tmp,
                "-out",
                p12_tmp,
                "-password",
                f"pass:{passphrase}",
            ]

            if legacy:
                version = get_openssl_version()
                if version and version >= b'3':
                    cmd.append("-legacy")

            run_process(
                cmd
            )

    Creates a pkcs12 formated file.
    :param cert:
    :param chain:
    :param p12_tmp:
    :param key:
    :param alias:
    :param passphrase:
    :param legacy: should legacy insecure encryption be used (for support with ancient Java versions)
    
lemur/plugins/lemur_openssl/plugin.py