def sign_file(conf, file):
    private = conf.configuration["CA_default"]["private_dir"]
    cert_file = conf.configuration["CA_default"]["certificate"]
    private_key = conf.configuration["CA_default"]["private_key"]
    password_file = os.path.join(private, "ca_password")

    try:
        with open(cert_file, 'rt') as f:
            cert_str = f.read()
            cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, cert_str)
            cert_hash = format(cert.subject_name_hash(),'x')
    except:
        _log.exception("Failed to get certificate hash")
        raise Exception("Failed to get certificate hash")
    sign_file = file + ".sign." + cert_hash
    log = subprocess.Popen(["openssl", "dgst", "-sha256",
                            "-sign", private_key,
                            "-passin", "file:" + password_file,
                            "-out", sign_file,
                            file],
                           stdout=subprocess.PIPE,
                           stderr=subprocess.PIPE)
    stdout, stderr = log.communicate()
    if log.returncode != 0:
        raise IOError(stderr)
    return sign_file
Run an analytics notebook.
dataset/ETHPy150Open EricssonResearch/calvin-base/calvin/utilities/certificate.py/sign_file--crossover with--dataset/ETHPy150Open tmetsch/suricate/bin/sdk.py/run_analytics