是否可以使用 python 创建具有 sha_hash 的 SHACertificate?

Is it possible to create a SHACertificate with a sha_hash using python?

https://firebase.google.com/docs/reference/admin/java/reference/com/google/firebase/projectmanagement/ShaCertificate

我发现使用 Java 可以做到这一点,我使用 PyJKS 创建了密钥库文件,该文件有一个 PrivateKeyEntry,其中包含供我使用的 sha1 指纹,但我不知道如何使用将其转换为 SHACertificate 或 sha_hash 以上传到 firebase

    key = crypto.PKey()
    key.generate_key(crypto.TYPE_RSA, 4096)

    cert = crypto.X509()
    cert.get_subject().organizationName = 'myorg'
    cert.get_subject().organizationalUnitName = alias
    cert.set_serial_number(473289472)
    cert.gmtime_adj_notBefore(0)
    cert.gmtime_adj_notAfter(365*24*60*60*100)
    cert.set_issuer(cert.get_subject())
    cert.set_pubkey(key)
    cert.sign(key, 'sha256')

    dumped_cert = crypto.dump_certificate(crypto.FILETYPE_PEM, cert)
    dumped_key = crypto.dump_privatekey(crypto.FILETYPE_PEM, key)
    
    pke = jks.PrivateKeyEntry.new(alias, [dumped_cert], dumped_key, 'rsa_raw')
    keystore = KeyStore.new('jks', [pke])
    keystore.save(filePath, password)
from cryptography.hazmat.primitives import hashes
from cryptography import x509

ks = jks.KeyStore.load(keystore, password)
    for alias, pk in ks.private_keys.items():
        cert = x509.load_der_x509_certificate((pk.cert_chain[0])[1])
        sha1 = project_management.SHACertificate(bytearray(cert.fingerprint(hashes.SHA1())).hex(), "SHA_1")