Pyxmlsec/xmlsec/libxml2 kullanarak bir XML dosyası imzalamaya çalışıyorum ama başarısız oluyor (sigCtx->signValueNode == NULL:error=100:assertion
).xmlsec1 işareti, komut satırında çalışır ancak Python kodunda başarısız olur
komut satırından çalıştırmak sorunsuz çalışır:
xmlsec1 sign --output signed.xml --pkcs12 c.pfx --pwd mypwd tobesigned.xml
Benim Python kodunu:
libxml2.initParser()
libxml2.substituteEntitiesDefault(1)
xmlsec.init()
xmlsec.cryptoAppInit(None)
xmlsec.cryptoInit()
doc_xml = libxml2.parseMemory(xml, len(xml))
signature_node = xmlsec.findNode(
doc_xml.getRootElement(),
xmlsec.NodeSignature,
xmlsec.DSigNs,
)
signer = xmlsec.DSigCtx()
key = xmlsec.cryptoAppKeyLoad(
filename=str(self.issuer.certificate.path),
format=xmlsec.KeyDataFormatPkcs12,
pwd=str(self.issuer.certificate_password),
pwdCallback=None,
pwdCallbackCtx=None,
)
signer.signKey = key
signer.sign(signature_node) # error!
...
Tam hata izlemesi:
func=xmlSecDSigCtxProcessSignatureNode:file=xmldsig.c:line=463:obj=unknown:subj=dsigCtx->signValueNode == NULL:error=100:assertion:
func=xmlSecDSigCtxSign:file=xmldsig.c:line=303:obj=unknown:subj=xmlSecDSigCtxSigantureProcessNode:error=1:xmlsec library function failed:
Herhangi bir ipucu?
Teşekkürler!
Sabit çatallar: https://github.com/aricaldeira/pyxmlsec – alanjds