本文整理汇总了C++中xmlSecError函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlSecError函数的具体用法?C++ xmlSecError怎么用?C++ xmlSecError使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlSecError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xmlSecOpenSSLInit
/**
* xmlSecOpenSSLInit:
*
* XMLSec library specific crypto engine initialization.
*
* Returns: 0 on success or a negative value otherwise.
*/
int
xmlSecOpenSSLInit (void) {
/* Check loaded xmlsec library version */
if(xmlSecCheckVersionExact() != 1) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecCheckVersionExact",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
return(-1);
}
if(xmlSecOpenSSLErrorsInit() < 0) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecOpenSSLErrorsInit",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
return(-1);
}
/* register our klasses */
if(xmlSecCryptoDLFunctionsRegisterKeyDataAndTransforms(xmlSecCryptoGetFunctions_openssl()) < 0) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecCryptoDLFunctionsRegisterKeyDataAndTransforms",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
return(-1);
}
return(0);
}
示例2: xmlSecNodeSetAddList
/**
* xmlSecNodeSetAddList:
* @nset: the pointer to currrent nodes set (or NULL).
* @newNSet: the pointer to new nodes set.
* @op: the operation type.
*
* Adds @newNSet to the @nset as child using operation @op.
*
* Returns the pointer to combined nodes set or NULL if an error
* occurs.
*/
EXPORT_C
xmlSecNodeSetPtr
xmlSecNodeSetAddList(xmlSecNodeSetPtr nset, xmlSecNodeSetPtr newNSet, xmlSecNodeSetOp op) {
xmlSecNodeSetPtr tmp1, tmp2;
xmlSecAssert2(newNSet != NULL, NULL);
tmp1 = xmlSecNodeSetCreate(newNSet->doc, NULL, xmlSecNodeSetList);
if(tmp1 == NULL) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecNodeSetCreate",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
return(NULL);
}
tmp1->children = newNSet;
tmp2 = xmlSecNodeSetAdd(nset, tmp1, op);
if(tmp2 == NULL) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecNodeSetAdd",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
xmlSecNodeSetDestroy(tmp1);
return(NULL);
}
return(tmp2);
}
示例3: xmlSecOpenSSLAppPkcs12LoadMemory
/**
* xmlSecOpenSSLAppPkcs12LoadMemory:
* @data: the PKCS12 binary data.
* @dataSize: the PKCS12 binary data size.
* @pwd: the PKCS12 file password.
* @pwdCallback: the password callback.
* @pwdCallbackCtx: the user context for password callback.
*
* Reads key and all associated certificates from the PKCS12 data in memory buffer.
* For uniformity, call xmlSecOpenSSLAppKeyLoad instead of this function. Pass
* in format=xmlSecKeyDataFormatPkcs12.
*
* Returns: pointer to the key or NULL if an error occurs.
*/
xmlSecKeyPtr
xmlSecOpenSSLAppPkcs12LoadMemory(const xmlSecByte* data, xmlSecSize dataSize,
const char *pwd, void* pwdCallback,
void* pwdCallbackCtx) {
BIO* bio;
xmlSecKeyPtr key;
xmlSecAssert2(data != NULL, NULL);
/* this would be a read only BIO, cast from const is ok */
bio = BIO_new_mem_buf((void*)data, dataSize);
if(bio == NULL) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"BIO_new_mem_buf",
XMLSEC_ERRORS_R_CRYPTO_FAILED,
"errno=%d",
errno);
return(NULL);
}
key = xmlSecOpenSSLAppPkcs12LoadBIO (bio, pwd, pwdCallback, pwdCallbackCtx);
if(key == NULL) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecOpenSSLAppPkcs12LoadBIO",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
BIO_free(bio);
return(NULL);
}
BIO_free(bio);
return(key);
}
示例4: xmlSecBase64CtxCreate
/**
* xmlSecBase64CtxCreate:
* @encode: the encode/decode flag (1 - encode, 0 - decode)
* @columns: the max line length.
*
* Allocates and initializes new base64 context.
*
* Returns: a pointer to newly created #xmlSecBase64Ctx structure
* or NULL if an error occurs.
*/
xmlSecBase64CtxPtr
xmlSecBase64CtxCreate(int encode, int columns) {
xmlSecBase64CtxPtr ctx;
int ret;
/*
* Allocate a new xmlSecBase64CtxPtr and fill the fields.
*/
ctx = (xmlSecBase64CtxPtr) xmlMalloc(sizeof(xmlSecBase64Ctx));
if (ctx == NULL) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
NULL,
XMLSEC_ERRORS_R_MALLOC_FAILED,
"sizeof(xmlSecBase64Ctx)=%d",
(int)sizeof(xmlSecBase64Ctx));
return(NULL);
}
ret = xmlSecBase64CtxInitialize(ctx, encode, columns);
if(ret < 0) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecBase64CtxInitialize",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
xmlSecBase64CtxDestroy(ctx);
return(NULL);
}
return(ctx);
}
示例5: xmlSecSoap11CheckEnvelope
/**
* xmlSecSoap11CheckEnvelope:
* @envNode: the pointer to <soap:Envelope> node.
*
* Validates <soap:Envelope> node structure.
*
* Returns: 1 if @envNode has a valid <soap:Envelope> element, 0 if it is
* not valid or a negative value if an error occurs.
*/
int
xmlSecSoap11CheckEnvelope(xmlNodePtr envNode) {
xmlNodePtr cur;
xmlSecAssert2(envNode != NULL, -1);
/* verify envNode itself */
if(!xmlSecCheckNodeName(envNode, xmlSecNodeEnvelope, xmlSecSoap11Ns)) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
xmlSecErrorsSafeString(xmlSecNodeEnvelope),
XMLSEC_ERRORS_R_NODE_NOT_FOUND,
XMLSEC_ERRORS_NO_MESSAGE);
return(0);
}
/* optional Header node first */
cur = xmlSecGetNextElementNode(envNode->children);
if((cur != NULL) && xmlSecCheckNodeName(cur, xmlSecNodeHeader, xmlSecSoap11Ns)) {
cur = xmlSecGetNextElementNode(cur->next);
}
/* required Body node is next */
if((cur == NULL) || !xmlSecCheckNodeName(cur, xmlSecNodeBody, xmlSecSoap11Ns)) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
xmlSecErrorsSafeString(xmlSecNodeBody),
XMLSEC_ERRORS_R_NODE_NOT_FOUND,
XMLSEC_ERRORS_NO_MESSAGE);
return(0);
}
return(1);
}
示例6: xmlSecMSCryptoInit
/**
* xmlSecMSCryptoInit:
*
* XMLSec library specific crypto engine initialization.
*
* Returns: 0 on success or a negative value otherwise.
*/
int
xmlSecMSCryptoInit (void) {
/* Check loaded xmlsec library version */
if(xmlSecCheckVersionExact() != 1) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecCheckVersionExact",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
return(-1);
}
/* set default errors callback for xmlsec to us */
xmlSecErrorsSetCallback(xmlSecMSCryptoErrorsDefaultCallback);
/* register our klasses */
if(xmlSecCryptoDLFunctionsRegisterKeyDataAndTransforms(xmlSecCryptoGetFunctions_mscrypto()) < 0) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecCryptoDLFunctionsRegisterKeyDataAndTransforms",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
return(-1);
}
return(0);
}
示例7: xmlSecEncCtxCreate
/**
* xmlSecEncCtxCreate:
* @keysMngr: the pointer to keys manager.
*
* Creates <enc:EncryptedData/> element processing context.
* The caller is responsible for destroying returned object by calling
* #xmlSecEncCtxDestroy function.
*
* Returns: pointer to newly allocated context object or NULL if an error
* occurs.
*/
xmlSecEncCtxPtr
xmlSecEncCtxCreate(xmlSecKeysMngrPtr keysMngr) {
xmlSecEncCtxPtr encCtx;
int ret;
encCtx = (xmlSecEncCtxPtr) xmlMalloc(sizeof(xmlSecEncCtx));
if(encCtx == NULL) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
NULL,
XMLSEC_ERRORS_R_MALLOC_FAILED,
"sizeof(xmlSecEncCtx)=%d",
sizeof(xmlSecEncCtx));
return(NULL);
}
ret = xmlSecEncCtxInitialize(encCtx, keysMngr);
if(ret < 0) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecEncCtxInitialize",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
xmlSecEncCtxDestroy(encCtx);
return(NULL);
}
return(encCtx);
}
示例8: xmlSecKeyDuplicate
/**
* xmlSecKeyDuplicate:
* @key: the pointer to the #xmlSecKey structure.
*
* Creates a duplicate of the given @key.
*
* Returns: the pointer to newly allocated #xmlSecKey structure
* or NULL if an error occurs.
*/
xmlSecKeyPtr
xmlSecKeyDuplicate(xmlSecKeyPtr key) {
xmlSecKeyPtr newKey;
int ret;
xmlSecAssert2(key != NULL, NULL);
newKey = xmlSecKeyCreate();
if(newKey == NULL) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecKeyCreate",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
return(NULL);
}
ret = xmlSecKeyCopy(newKey, key);
if(ret < 0) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecKeyCopy",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
xmlSecKeyDestroy(newKey);
return(NULL);
}
return(newKey);
}
示例9: xmlSecXPathDataNodeRead
static int
xmlSecXPathDataNodeRead(xmlSecXPathDataPtr data, xmlNodePtr node) {
int ret;
xmlSecAssert2(data != NULL, -1);
xmlSecAssert2(data->expr == NULL, -1);
xmlSecAssert2(data->ctx != NULL, -1);
xmlSecAssert2(node != NULL, -1);
ret = xmlSecXPathDataRegisterNamespaces (data, node);
if(ret < 0) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecXPathDataRegisterNamespaces",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
return(-1);
}
/* read node content and set expr */
data->expr = xmlNodeGetContent(node);
if(data->expr == NULL) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
xmlSecErrorsSafeString(xmlSecNodeGetName(node)),
XMLSEC_ERRORS_R_INVALID_NODE_CONTENT,
XMLSEC_ERRORS_NO_MESSAGE);
return(-1);
}
return(0);
}
示例10: xmlSecKeyUseWithDuplicate
/**
* xmlSecKeyUseWithDuplicate:
* @keyUseWith: the pointer to information about key application/user.
*
* Duplicates @keyUseWith object. The caller is responsible for destroying
* returned object with @xmlSecKeyUseWithDestroy function.
*
* Returns: pointer to newly created object or NULL if an error occurs.
*/
xmlSecKeyUseWithPtr
xmlSecKeyUseWithDuplicate(xmlSecKeyUseWithPtr keyUseWith) {
int ret;
xmlSecKeyUseWithPtr newKeyUseWith;
xmlSecAssert2(keyUseWith != NULL, NULL);
newKeyUseWith = xmlSecKeyUseWithCreate(NULL, NULL);
if(newKeyUseWith == NULL) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecKeyUseWithCreate",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
return(NULL);
}
ret = xmlSecKeyUseWithCopy(newKeyUseWith, keyUseWith);
if(ret < 0) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecKeyUseWithCopy",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
xmlSecKeyUseWithDestroy(keyUseWith);
return(NULL);
}
return(newKeyUseWith);
}
示例11: xmlSecKeyDataIdsInit
/**
* xmlSecKeyDataIdsInit:
*
* Initializes the key data klasses. This function is called from the
* #xmlSecInit function and the application should not call it directly.
*
* Returns: 0 on success or a negative value if an error occurs.
*/
int
xmlSecKeyDataIdsInit(void) {
int ret;
ret = xmlSecPtrListInitialize(xmlSecKeyDataIdsGet(), xmlSecKeyDataIdListId);
if(ret < 0) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecPtrListPtrInitialize",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
"xmlSecKeyDataIdListId");
return(-1);
}
ret = xmlSecKeyDataIdsRegisterDefault();
if(ret < 0) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecKeyDataIdsRegisterDefault",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
return(-1);
}
return(0);
}
示例12: xmlSecKeyDataDuplicate
/**
* xmlSecKeyDataDuplicate:
* @data: the pointer to the key data.
*
* Creates a duplicate of the given @data. Caller is responsible for
* destroying returned object with #xmlSecKeyDataDestroy function.
*
* Returns: the pointer to newly allocated key data structure
* or NULL if an error occurs.
*/
xmlSecKeyDataPtr
xmlSecKeyDataDuplicate(xmlSecKeyDataPtr data) {
xmlSecKeyDataPtr newData;
int ret;
xmlSecAssert2(xmlSecKeyDataIsValid(data), NULL);
xmlSecAssert2(data->id->duplicate != NULL, NULL);
newData = xmlSecKeyDataCreate(data->id);
if(newData == NULL) {
xmlSecError(XMLSEC_ERRORS_HERE,
xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
"xmlSecKeyDataCreate",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
return(NULL);
}
ret = (data->id->duplicate)(newData, data);
if(ret < 0) {
xmlSecError(XMLSEC_ERRORS_HERE,
xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
"id->duplicate",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
xmlSecKeyDataDestroy(newData);
return(NULL);
}
return(newData);
}
示例13: xmlSecOpenSSLKeysMngrInit
/**
* xmlSecOpenSSLKeysMngrInit:
* @mngr: the pointer to keys manager.
*
* Adds OpenSSL specific key data stores in keys manager.
*
* Returns: 0 on success or a negative value otherwise.
*/
int
xmlSecOpenSSLKeysMngrInit(xmlSecKeysMngrPtr mngr) {
int ret;
xmlSecAssert2(mngr != NULL, -1);
#ifndef XMLSEC_NO_X509
/* create x509 store if needed */
if(xmlSecKeysMngrGetDataStore(mngr, xmlSecOpenSSLX509StoreId) == NULL) {
xmlSecKeyDataStorePtr x509Store;
x509Store = xmlSecKeyDataStoreCreate(xmlSecOpenSSLX509StoreId);
if(x509Store == NULL) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecKeyDataStoreCreate",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
"xmlSecOpenSSLX509StoreId");
return(-1);
}
ret = xmlSecKeysMngrAdoptDataStore(mngr, x509Store);
if(ret < 0) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecKeysMngrAdoptDataStore",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
xmlSecKeyDataStoreDestroy(x509Store);
return(-1);
}
}
#endif /* XMLSEC_NO_X509 */
return(0);
}
示例14: xmlSecOpenSSLAppInit
/**
* xmlSecOpenSSLAppInit:
* @config: the path to certs.
*
* General crypto engine initialization. This function is used
* by XMLSec command line utility and called before
* @xmlSecInit function.
*
* Returns: 0 on success or a negative value otherwise.
*/
int
xmlSecOpenSSLAppInit(const char* config) {
ERR_load_crypto_strings();
#ifndef XMLSEC_OPENSSL_110
OPENSSL_config(NULL);
#endif
OpenSSL_add_all_algorithms();
if((RAND_status() != 1) && (xmlSecOpenSSLAppLoadRANDFile(NULL) != 1)) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecOpenSSLAppLoadRANDFile",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
return(-1);
}
if((config != NULL) && (xmlSecOpenSSLSetDefaultTrustedCertsFolder(BAD_CAST config) < 0)) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
"xmlSecOpenSSLSetDefaultTrustedCertsFolder",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
return(-1);
}
return(0);
}
示例15: xmlSecOpenSSLX509StoreAddCertsFile
/**
* xmlSecOpenSSLX509StoreAddCertsFile:
* @store: the pointer to OpenSSL x509 store.
* @file: the certs file.
*
* Adds all certs in @file to the list of trusted certs
* in @store. It is possible for @file to contain multiple certs.
*
* Returns: 0 on success or a negative value otherwise.
*/
int
xmlSecOpenSSLX509StoreAddCertsFile(xmlSecKeyDataStorePtr store, const char *file) {
xmlSecOpenSSLX509StoreCtxPtr ctx;
X509_LOOKUP *lookup = NULL;
xmlSecAssert2(xmlSecKeyDataStoreCheckId(store, xmlSecOpenSSLX509StoreId), -1);
xmlSecAssert2(file != NULL, -1);
ctx = xmlSecOpenSSLX509StoreGetCtx(store);
xmlSecAssert2(ctx != NULL, -1);
xmlSecAssert2(ctx->xst != NULL, -1);
lookup = X509_STORE_add_lookup(ctx->xst, X509_LOOKUP_file());
if(lookup == NULL) {
xmlSecError(XMLSEC_ERRORS_HERE,
xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
"X509_STORE_add_lookup",
XMLSEC_ERRORS_R_CRYPTO_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
return(-1);
}
if(!X509_LOOKUP_load_file(lookup, file, X509_FILETYPE_PEM)) {
xmlSecError(XMLSEC_ERRORS_HERE,
xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
"X509_LOOKUP_load_file",
XMLSEC_ERRORS_R_CRYPTO_FAILED,
"file='%s'",
xmlSecErrorsSafeString(file)
);
return(-1);
}
return(0);
}