5
pyxmlsec/xmlsec/libxml2를 사용하여 XML 파일에 서명하려고하는데 실패 (sigCtx->signValueNode == NULL:error=100:assertion
)합니다.xmlsec1 기호는 명령 행에서 작동하지만 파이썬 코드에서는 실패합니다.
내가 명령 줄에서 실행이 원활하게 작동합니다
xmlsec1 sign --output signed.xml --pkcs12 c.pfx --pwd mypwd tobesigned.xml
내 파이썬 코드 :
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!
...
전체 오류 추적 :
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:
모든 팁을?
감사합니다.
고정 포크 : https://github.com/aricaldeira/pyxmlsec – alanjds