XML Security Library

LibXML2
LibXSLT
OpenSSL

Initialization and shutdown.

XML Security Library initialization/shutdown process includes initialization and shutdown of the dependent libraries:

  • libxml library;

  • libxslt library;

  • crypto library (OpenSSL, GnuTLS, NSS, ...);

  • xmlsec library (xmlSecInit and xmlSecShutdown functions);

  • xmlsec-crypto library (xmlSecCryptoInit and xmlSecCryptoShutdown functions);

xmlsec-crypto library also provides a convinient functions xmlSecAppCryptoInit and xmlSecAppCryptoShutdown to initialize the crypto library itself but application can do it by itself.

Example 2. Initializing application.

    /* Init libxml and libxslt libraries */
    xmlInitParser();
    LIBXML_TEST_VERSION
    xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
    xmlSubstituteEntitiesDefault(1);
#ifndef XMLSEC_NO_XSLT
    xmlIndentTreeOutput = 1; 
#endif /* XMLSEC_NO_XSLT */
        	
    /* Init xmlsec library */
    if(xmlSecInit() < 0) {
	fprintf(stderr, "Error: xmlsec initialization failed.\n");
	return(-1);
    }

    /* Init crypto library */
    if(xmlSecCryptoAppInit(NULL) < 0) {
	fprintf(stderr, "Error: crypto initialization failed.\n");
	return(-1);
    }

    /* Init xmlsec-crypto library */
    if(xmlSecCryptoInit() < 0) {
	fprintf(stderr, "Error: xmlsec-crypto initialization failed.\n");
	return(-1);
    }
		

Example 3. Shutting down application.

    /* Shutdown xmlsec-crypto library */
    xmlSecCryptoShutdown();
    
    /* Shutdown crypto library */
    xmlSecCryptoAppShutdown();
    
    /* Shutdown xmlsec library */
    xmlSecShutdown();

    /* Shutdown libxslt/libxml */
#ifndef XMLSEC_NO_XSLT
    xsltCleanupGlobals();            
#endif /* XMLSEC_NO_XSLT */
    xmlCleanupParser();		
		


Aleksey Sanin