1 <chapter id="xmlsec-notes-init-shutdown">
2 <title>Initialization and shutdown.</title>
3 <para>XML Security Library initialization/shutdown
4 process includes initialization and shutdown of the
7 <listitem><para>libxml library;</para></listitem>
8 <listitem><para>libxslt library;</para></listitem>
9 <listitem><para>crypto library (OpenSSL, GnuTLS, NSS, ...);</para></listitem>
10 <listitem><para>xmlsec library
11 (<link linkend="xmlSecInit">xmlSecInit</link>
12 and <link linkend="xmlSecShutdown">xmlSecShutdown</link>
15 <listitem><para>xmlsec-crypto library
16 (<link linkend="xmlSecCryptoDLLoadLibrary">xmlSecCryptoDLLoadLibrary</link>
17 to load xmlsec-crypto library dynamicaly if needed,
18 <link linkend="xmlSecCryptoInit">xmlSecCryptoInit</link>
19 and <link linkend="xmlSecCryptoShutdown">xmlSecCryptoShutdown</link>
23 xmlsec-crypto library also provides a convinient functions
24 <link linkend="xmlSecAppCryptoInit">xmlSecAppCryptoInit</link>
25 and <link linkend="xmlSecAppCryptoShutdown">xmlSecAppCryptoShutdown</link>
26 to initialize the crypto library itself but application can do it
31 <title>Initializing application.</title>
32 <programlisting><![CDATA[
33 /* Init libxml and libxslt libraries */
36 xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
37 xmlSubstituteEntitiesDefault(1);
38 #ifndef XMLSEC_NO_XSLT
39 xmlIndentTreeOutput = 1;
40 #endif /* XMLSEC_NO_XSLT */
42 /* Init xmlsec library */
43 if(xmlSecInit() < 0) {
44 fprintf(stderr, "Error: xmlsec initialization failed.\n");
48 /* Check loaded library version */
49 if(xmlSecCheckVersion() != 1) {
50 fprintf(stderr, "Error: loaded xmlsec library version is not compatible.\n");
54 /* Load default crypto engine if we are supporting dynamic
55 * loading for xmlsec-crypto libraries. Use the crypto library
56 * name ("openssl", "nss", etc.) to load corresponding
57 * xmlsec-crypto library.
59 #ifdef XMLSEC_CRYPTO_DYNAMIC_LOADING
60 if(xmlSecCryptoDLLoadLibrary(BAD_CAST XMLSEC_CRYPTO) < 0) {
61 fprintf(stderr, "Error: unable to load default xmlsec-crypto library. Make sure\n"
62 "that you have it installed and check shared libraries path\n"
63 "(LD_LIBRARY_PATH) envornment variable.\n");
66 #endif /* XMLSEC_CRYPTO_DYNAMIC_LOADING */
68 /* Init crypto library */
69 if(xmlSecCryptoAppInit(NULL) < 0) {
70 fprintf(stderr, "Error: crypto initialization failed.\n");
74 /* Init xmlsec-crypto library */
75 if(xmlSecCryptoInit() < 0) {
76 fprintf(stderr, "Error: xmlsec-crypto initialization failed.\n");
85 <title>Shutting down application.</title>
86 <programlisting><![CDATA[
87 /* Shutdown xmlsec-crypto library */
88 xmlSecCryptoShutdown();
90 /* Shutdown crypto library */
91 xmlSecCryptoAppShutdown();
93 /* Shutdown xmlsec library */
96 /* Shutdown libxslt/libxml */
97 #ifndef XMLSEC_NO_XSLT
99 #endif /* XMLSEC_NO_XSLT */