本文整理汇总了Python中xmlsec.cryptoAppInit函数的典型用法代码示例。如果您正苦于以下问题:Python cryptoAppInit函数的具体用法?Python cryptoAppInit怎么用?Python cryptoAppInit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cryptoAppInit函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _inicializar_cripto
def _inicializar_cripto(self):
libxml2.initParser()
libxml2.substituteEntitiesDefault(1)
xmlsec.init()
xmlsec.cryptoAppInit(None)
xmlsec.cryptoInit()
开发者ID:danimaribeiro,项目名称:PyTrustNFe,代码行数:7,代码来源:assinatura.py
示例2: received
def received(self, context):
self.poruka_odgovor = context.reply
libxml2.initParser()
libxml2.substituteEntitiesDefault(1)
xmlsec.init()
xmlsec.cryptoAppInit(None)
xmlsec.cryptoInit()
mngr = xmlsec.KeysMngr()
xmlsec.cryptoAppDefaultKeysMngrInit(mngr)
#mngr.certLoad(verifyCertFile, xmlsec.KeyDataFormatPem, xmlsec.KeyDataTypeTrusted)
mngr.certLoad(certFile, xmlsec.KeyDataFormatPem, xmlsec.KeyDataTypeTrusted)
doc = libxml2.parseDoc(context.reply)
xmlsec.addIDs(doc, doc.getRootElement(), ['Id'])
node = xmlsec.findNode(doc.getRootElement(), xmlsec.NodeSignature, xmlsec.DSigNs)
dsig_ctx = xmlsec.DSigCtx(mngr)
dsig_ctx.verify(node)
if(dsig_ctx.status == xmlsec.DSigStatusSucceeded): self.valid_signature = 1
xmlsec.cryptoShutdown()
xmlsec.cryptoAppShutdown()
xmlsec.shutdown()
libxml2.cleanupParser()
return context
开发者ID:jerko,项目名称:fiskal_v70,代码行数:27,代码来源:fiskal.py
示例3: sending
def sending(self, context):
msgtype = "RacunZahtjev"
if "PoslovniProstorZahtjev" in context.envelope: msgtype = "PoslovniProstorZahtjev"
doc2 = libxml2.parseDoc(context.envelope)
zahtjev = doc2.xpathEval('//*[local-name()="%s"]' % msgtype)[0]
doc2.setRootElement(zahtjev)
x = doc2.getRootElement().newNs('http://www.apis-it.hr/fin/2012/types/f73', 'tns')
for i in doc2.xpathEval('//*'):
i.setNs(x)
libxml2.initParser()
libxml2.substituteEntitiesDefault(1)
xmlsec.init()
xmlsec.cryptoAppInit(None)
xmlsec.cryptoInit()
doc2.getRootElement().setProp('Id', msgtype)
xmlsec.addIDs(doc2, doc2.getRootElement(), ['Id'])
signNode = xmlsec.TmplSignature(doc2, xmlsec.transformExclC14NId(), xmlsec.transformRsaSha1Id(), None)
doc2.getRootElement().addChild(signNode)
refNode = signNode.addReference(xmlsec.transformSha1Id(), None, None, None)
refNode.setProp('URI', '#%s' % msgtype)
refNode.addTransform(xmlsec.transformEnvelopedId())
refNode.addTransform(xmlsec.transformExclC14NId())
dsig_ctx = xmlsec.DSigCtx()
key = xmlsec.cryptoAppKeyLoad(keyFile, xmlsec.KeyDataFormatPem, None, None, None)
dsig_ctx.signKey = key
xmlsec.cryptoAppKeyCertLoad(key, certFile, xmlsec.KeyDataFormatPem)
key.setName(keyFile)
keyInfoNode = signNode.ensureKeyInfo(None)
x509DataNode = keyInfoNode.addX509Data()
xmlsec.addChild(x509DataNode, "X509IssuerSerial")
xmlsec.addChild(x509DataNode, "X509Certificate")
dsig_ctx.sign(signNode)
if dsig_ctx is not None: dsig_ctx.destroy()
context.envelope = """<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>""" + doc2.serialize().replace('<?xml version="1.0" encoding="UTF-8"?>','') + """</soapenv:Body></soapenv:Envelope>""" # Ugly hack
# Shutdown xmlsec-crypto library, ako ne radi HTTPS onda ovo treba zakomentirati da ga ne ugasi prije reda
xmlsec.cryptoShutdown()
xmlsec.shutdown()
libxml2.cleanupParser()
return context
开发者ID:jerko,项目名称:fiskal_v70,代码行数:58,代码来源:fiskal.py
示例4: _inicia_funcoes_externas
def _inicia_funcoes_externas(self):
# Ativa as funções de análise de arquivos XML
libxml2.initParser()
libxml2.substituteEntitiesDefault(1)
# Ativa as funções da API de criptografia
xmlsec.init()
xmlsec.cryptoAppInit(None)
xmlsec.cryptoInit()
开发者ID:Anferi,项目名称:PySPED,代码行数:9,代码来源:certificado.py
示例5: _ativar_funcoes_criptograficas
def _ativar_funcoes_criptograficas(self):
# FIXME: descobrir forma de evitar o uso do libxml2 neste processo
# Ativa as funções de análise de arquivos XML FIXME
libxml2.initParser()
libxml2.substituteEntitiesDefault(1)
# Ativa as funções da API de criptografia
xmlsec.init()
xmlsec.cryptoAppInit(None)
xmlsec.cryptoInit()
开发者ID:danielgoncalves,项目名称:PyNFe,代码行数:11,代码来源:assinatura.py
示例6: init_xmlsec
def init_xmlsec(self):
# Init libxml library
libxml2.initParser()
libxml2.substituteEntitiesDefault(1)
# Init xmlsec library
if xmlsec.init() < 0:
log.error(" xmlsec initialization failed.")
# XXX This should do something else...
return sys.exit(-1)
# Check loaded library version
if xmlsec.checkVersion() != 1:
log.error(" loaded xmlsec library version is not compatible.\n")
sys.exit(-1)
# Init crypto library
if xmlsec.cryptoAppInit(None) < 0:
log.error(" crypto initialization failed.")
# Init xmlsec-crypto library
if xmlsec.cryptoInit() < 0:
log.error(" xmlsec-crypto initialization failed.")
self._init_xmlsec = True
开发者ID:galacticsurfer,项目名称:pyAadhaarAuth,代码行数:26,代码来源:signature.py
示例7: init
def init():
global secinit
if secinit:
return
# Init libxml library
libxml2.initParser()
libxml2.substituteEntitiesDefault(1)
# Init xmlsec library
if xmlsec.init() < 0:
print "Error: xmlsec initialization failed."
return sys.exit(-1)
# Check loaded library version
if xmlsec.checkVersion() != 1:
print "Error: loaded xmlsec library version is not compatible.\n"
sys.exit(-1)
# Init crypto library
if xmlsec.cryptoAppInit(None) < 0:
print "Error: crypto initialization failed."
# Init xmlsec-crypto library
if xmlsec.cryptoInit() < 0:
print "Error: xmlsec-crypto initialization failed."
secinit = True
开发者ID:driedtoast,项目名称:identitycert,代码行数:26,代码来源:__init__.py
示例8: __init__
def __init__(self, logging):
self.logging = logging
self.logging.debug("Starting crypto engine")
# Init libxml library
libxml2.initParser()
libxml2.substituteEntitiesDefault(1)
# Init xmlsec library
if xmlsec.init() < 0:
print "Error: xmlsec initialization failed."
return sys.exit(-1)
# Check loaded library version
if xmlsec.checkVersion() != 1:
self.logging.error("loaded xmlsec library version is not compatible.")
sys.exit(-1)
# Init crypto library
if xmlsec.cryptoAppInit(None) < 0:
self.logging.error("crypto initialization failed.")
# Init xmlsec-crypto library
if xmlsec.cryptoInit() < 0:
self.logging.error("xmlsec-crypto initialization failed.")
开发者ID:nesl,项目名称:esp,代码行数:27,代码来源:espsec.py
示例9: init_xmlsec
def init_xmlsec():
libxml2.initParser()
libxml2.substituteEntitiesDefault(1)
if xmlsec.init() < 0:
raise RuntimeError('xmlsec initialization failed')
if xmlsec.checkVersion() != 1:
raise RuntimeError('loaded xmlsec library version is not compatible')
if xmlsec.cryptoAppInit(None) < 0:
raise RuntimeError('crypto initialization failed')
if xmlsec.cryptoInit() < 0:
raise RuntimeError('xmlsec-crypto initialization failed')
开发者ID:Se7ge,项目名称:SudsSigner,代码行数:11,代码来源:xmlsec_wrapper.py
示例10: init
def init():
# Init libxml library
libxml2.initParser()
libxml2.substituteEntitiesDefault(1)
# Init xmlsec library
assert xmlsec.init() >= 0, "Error: xmlsec initialization failed."
# Check loaded library version
assert xmlsec.checkVersion() == 1, "Error: loaded xmlsec library version is not compatible."
# Init crypto library
assert xmlsec.cryptoAppInit(None) >= 0, "Error: crypto initialization failed."
# Init xmlsec-crypto library
assert xmlsec.cryptoInit() >= 0, "Error: xmlsec-crypto initialization failed."
开发者ID:jotaylor,项目名称:cos_monitoring,代码行数:12,代码来源:SignStsciRequest.py
示例11: main
def main():
assert(sys.argv)
if len(sys.argv) < 3:
print "Error: wrong number of arguments."
print "Usage: %s <xml-file> <key-file1> [<key-file2> [...]]" % sys.argv[0]
return sys.exit(1)
# Init libxml library
libxml2.initParser()
libxml2.substituteEntitiesDefault(1)
# Init xmlsec library
if xmlsec.init() < 0:
print "Error: xmlsec initialization failed."
return sys.exit(-1)
# Check loaded library version
if xmlsec.checkVersion() != 1:
print "Error: loaded xmlsec library version is not compatible.\n"
sys.exit(-1)
# Init crypto library
if xmlsec.cryptoAppInit(None) < 0:
print "Error: crypto initialization failed."
# Init xmlsec-crypto library
if xmlsec.cryptoInit() < 0:
print "Error: xmlsec-crypto initialization failed."
# Create keys manager and load keys
mngr = load_keys(sys.argv[2:], len(sys.argv) - 2)
res = 0
# Verify file
if mngr is not None:
res = verify_file(mngr, sys.argv[1])
# Destroy keys manager
mngr.destroy()
# Shutdown xmlsec-crypto library
xmlsec.cryptoShutdown()
# Shutdown crypto library
xmlsec.cryptoAppShutdown()
# Shutdown xmlsec library
xmlsec.shutdown()
# Shutdown LibXML2
libxml2.cleanupParser()
sys.exit(res)
开发者ID:artur-kacen,项目名称:pyxmlsec,代码行数:52,代码来源:verify2.py
示例12: main
def main():
assert(sys.argv)
if len(sys.argv) != 2:
print "Error: wrong number of arguments."
print "Usage: %s <enc-file>" % sys.argv[0]
return sys.exit(1)
res = 0
# Init libxml library
libxml2.initParser()
libxml2.substituteEntitiesDefault(1)
# Init xmlsec library
if xmlsec.init() < 0:
print "Error: xmlsec initialization failed."
return sys.exit(-1)
# Check loaded library version
if xmlsec.checkVersion() != 1:
print "Error: loaded xmlsec library version is not compatible."
sys.exit(-1)
# Init crypto library
if xmlsec.cryptoAppInit(None) < 0:
print "Error: crypto initialization failed."
# Init xmlsec-crypto library
if xmlsec.cryptoInit() < 0:
print "Error: xmlsec-crypto initialization failed."
# Create keys manager and load keys */
mngr = create_files_keys_mngr()
if mngr is not None:
res = decrypt_file(mngr, sys.argv[1])
# Shutdown xmlsec-crypto library
xmlsec.cryptoShutdown()
# Shutdown crypto library
xmlsec.cryptoAppShutdown()
# Shutdown xmlsec library
xmlsec.shutdown()
# Shutdown LibXML2
libxml2.cleanupParser()
sys.exit(res)
开发者ID:dnet,项目名称:pyxmlsec,代码行数:49,代码来源:decrypt3.py
示例13: _init
def _init():
"""Initializes the libxml2 parser and XMLSEC library. Is called
automatically upon loading this module.
"""
# Initiate the libxml2 parser
libxml2.initParser()
libxml2.substituteEntitiesDefault(1)
# Initialize xmlsec
if xmlsec.init() < 0:
raise DSigError("Failed initializing xmlsec library")
if xmlsec.cryptoAppInit(None) < 0:
raise DSigError("Failed initializing crypto library")
if xmlsec.cryptoInit() < 0:
raise DSigError("Failed initializing xmlsec-crypto library")
开发者ID:ralphje,项目名称:python-xmlsec,代码行数:15,代码来源:dsig.py
示例14: main
def main():
secret_data = "Big secret"
assert(sys.argv)
if len(sys.argv) < 3:
print "Error: wrong number of arguments."
print "Usage: %s <xml-tmpl> <des-key-file>" % sys.argv[0]
return sys.exit(1)
# Init libxml library
libxml2.initParser()
libxml2.substituteEntitiesDefault(1)
# Init xmlsec library
if xmlsec.init() < 0:
print "Error: xmlsec initialization failed."
return sys.exit(-1)
# Check loaded library version
if xmlsec.checkVersion() != 1:
print "Error: loaded xmlsec library version is not compatible.\n"
sys.exit(-1)
# Init crypto library
if xmlsec.cryptoAppInit(None) < 0:
print "Error: crypto initialization failed."
# Init xmlsec-crypto library
if xmlsec.cryptoInit() < 0:
print "Error: xmlsec-crypto initialization failed."
res = encrypt_file(sys.argv[1], sys.argv[2], secret_data, len(secret_data))
# Shutdown xmlsec-crypto library
xmlsec.cryptoShutdown()
# Shutdown crypto library
xmlsec.cryptoAppShutdown()
# Shutdown xmlsec library
xmlsec.shutdown()
# Shutdown LibXML2
libxml2.cleanupParser()
sys.exit(res)
开发者ID:artur-kacen,项目名称:pyxmlsec,代码行数:46,代码来源:encrypt1.py
示例15: lib_init
def lib_init():
# Init libxml library
libxml2.initParser()
libxml2.substituteEntitiesDefault(1)
# Init xmlsec library
if xmlsec.init() < 0:
raise(saml2.Error("Error: xmlsec initialization failed."))
# Check loaded library version
if xmlsec.checkVersion() != 1:
raise(saml2.Error(
"Error: loaded xmlsec library version is not compatible.\n"))
# Init crypto library
if xmlsec.cryptoAppInit(None) < 0:
raise(saml2.Error("Error: crypto initialization failed."))
# Init xmlsec-crypto library
if xmlsec.cryptoInit() < 0:
raise(saml2.Error("Error: xmlsec-crypto initialization failed."))
开发者ID:imraneyim,项目名称:python-saml2,代码行数:21,代码来源:utils.py
示例16: _signXML
def _signXML(self, xml):
import libxml2
import xmlsec
dsigctx = None
doc = None
try:
# initialization
libxml2.initParser()
libxml2.substituteEntitiesDefault(1)
if xmlsec.init() < 0:
raise SignatureError('xmlsec init failed')
if xmlsec.checkVersion() != 1:
raise SignatureError('incompatible xmlsec library version %s' %
str(xmlsec.checkVersion()))
if xmlsec.cryptoAppInit(None) < 0:
raise SignatureError('crypto initialization failed')
if xmlsec.cryptoInit() < 0:
raise SignatureError('xmlsec-crypto initialization failed')
# load the input
doc = libxml2.parseDoc(xml)
if not doc or not doc.getRootElement():
raise SignatureError('error parsing input xml')
node = xmlsec.findNode(doc.getRootElement(), xmlsec.NodeSignature,
xmlsec.DSigNs)
if not node:
raise SignatureError("couldn't find root node")
# load the private key
key = xmlsec.cryptoAppKeyLoad(self.key_file, xmlsec.KeyDataFormatPem,
self.key_pwd, None, None)
if not key:
raise SignatureError('failed to load the private key %s' % self.key_file)
if xmlsec.cryptoAppKeyCertLoad(key, self.cert_file, xmlsec.KeyDataFormatPem) < 0:
print "Error: failed to load pem certificate \"%s\"" % self.cert_file
return self.cleanup(doc, dsigctx)
keymngr = xmlsec.KeysMngr()
xmlsec.cryptoAppDefaultKeysMngrInit(keymngr)
xmlsec.cryptoAppDefaultKeysMngrAdoptKey(keymngr, key)
dsigctx = xmlsec.DSigCtx(keymngr)
if key.setName(self.key_file) < 0:
raise SignatureError('failed to set key name')
# sign
if dsigctx.sign(node) < 0:
raise SignatureError('signing failed')
signed_xml = doc.serialize()
finally:
if dsigctx:
dsigctx.destroy()
if doc:
doc.freeDoc()
xmlsec.cryptoShutdown()
xmlsec.shutdown()
libxml2.cleanupParser()
return signed_xml
开发者ID:joesoc,项目名称:gsa-admin-toolkit,代码行数:61,代码来源:authn.py
示例17:
from __future__ import division, print_function, unicode_literals
import libxml2
import xmlsec
import os
DIRNAME = os.path.dirname(__file__)
if __name__ == u'__main__':
certificados = os.listdir(DIRNAME + 'certificados')
certificados.sort() # ?????
# Ativa as funções da API de criptografia
xmlsec.init()
xmlsec.cryptoAppInit(None)
xmlsec.cryptoInit()
#
# Prepara o gerenciador dos certificados confiáveis
#
certificados_confiaveis = xmlsec.KeysMngr()
xmlsec.cryptoAppDefaultKeysMngrInit(certificados_confiaveis)
for certificado in certificados:
certificados_confiaveis.certLoad(filename=str(DIRNAME + 'certificados/' + certificado), format=xmlsec.KeyDataFormatPem, type=xmlsec.KeyDataTypeTrusted)
xmlsec.cryptoShutdown()
xmlsec.cryptoAppShutdown()
xmlsec.shutdown()
开发者ID:crsilveira,项目名称:PySPED-Tools,代码行数:30,代码来源:testa-carga-certificados.py
示例18: _verifyXML
def _verifyXML(self, xml):
import libxml2
import xmlsec
dsigctx = None
doc = None
try:
# initialization
libxml2.initParser()
libxml2.substituteEntitiesDefault(1)
if xmlsec.init() < 0:
raise SignatureError('xmlsec init failed')
if xmlsec.checkVersion() != 1:
raise SignatureError('incompatible xmlsec library version %s' %
str(xmlsec.checkVersion()))
if xmlsec.cryptoAppInit(None) < 0:
raise SignatureError('crypto initialization failed')
if xmlsec.cryptoInit() < 0:
raise SignatureError('xmlsec-crypto initialization failed')
# load the input
doc = libxml2.parseDoc(xml)
if not doc or not doc.getRootElement():
raise SignatureError('error parsing input xml')
node = xmlsec.findNode(doc.getRootElement(), xmlsec.NodeSignature,
xmlsec.DSigNs)
if not node:
raise SignatureError("couldn't find root node")
dsigctx = xmlsec.DSigCtx()
key = xmlsec.cryptoAppKeyLoad(self.key_file, xmlsec.KeyDataFormatPem,
self.key_pwd, None, None)
if not key:
raise SignatureError('failed to load the private key %s' % self.key_file)
dsigctx.signKey = key
if key.setName(self.key_file) < 0:
raise SignatureError('failed to set key name')
if xmlsec.cryptoAppKeyCertLoad(key, self.cert_file, xmlsec.KeyDataFormatPem) < 0:
print "Error: failed to load pem certificate \"%s\"" % self.cert_file
return self.cleanup(doc, dsigctx)
# verify
if dsigctx.verify(node) < 0:
raise SignatureError('verification failed')
if dsigctx.status == xmlsec.DSigStatusSucceeded:
self.log("Signature is OK")
is_valid = True
else:
self.log("***************** Signature is INVALID ********************")
is_valid = False
finally:
if dsigctx:
dsigctx.destroy()
if doc:
doc.freeDoc()
xmlsec.cryptoShutdown()
xmlsec.shutdown()
libxml2.cleanupParser()
return is_valid
开发者ID:salrashid123,项目名称:googlapps-sso,代码行数:64,代码来源:saml_sp.py
注:本文中的xmlsec.cryptoAppInit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论