Есть ли способ изменить подпись сертификата x509 в кодировке PEM с помощью python?
Я пытался использовать модуль python для криптографии, но, похоже, атрибут подписи x509 не устанавливается.Я могу только получить его значение.Есть ли другой модуль Python, который мог бы работать лучше для этой цели?
Документация по модулю криптографии Python находится здесь: https://cryptography.io/en/latest/x509/reference/#x-509-certificate-object
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.serialization import Encoding
import os
#change the signature of the cert
def change_cert_sig(pem_data):
cert = x509.load_pem_x509_certificate(pem_data, default_backend())
#the line below works
print(cert.signature)
#the line below causes an exception "AttributeError: can't set attribute"
cert.set_signature(os.urandom(len(cert.signature))) #set signature to random bytes
return cert.public_bytes(Encoding.PEM)