---
product: Chilkat
product_version: 11.7.0
language: c
language_label: C
class: XmlCertVault
license: free
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/c_CkXmlCertVaultRef.html
---
# Chilkat XmlCertVault — C — v11.7.0

> Chilkat 11.7.0 · language=c · class=XmlCertVault
> Other versions: replace `11.7.0` in this URL. Other languages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/<lang>/classes/XmlCertVault.md`.
> Language-wide rules (install, unlock, error model, strings/bytes): `https://www.chilkatsoft.com/ai-docs/v/11.7.0/c/guide.md`.

## Purpose

**Collect certificates, certificate chains, PEM data, and PFX private keys in an XML vault.**

`Chilkat.XmlCertVault` stores certificates and private-key material in a portable XML-based certificate vault. It can add individual certificates, certificate chains, DER or encoded certificates, PEM files, certificate strings, and PFX/PKCS12 data from files, memory, encoded text, or existing Chilkat objects. The vault can then be exported as XML, loaded from XML, or saved to an XML file for later reuse by other Chilkat certificate and TLS workflows.

**Add certificates**

Add certificates from `Cert` objects, files, PEM strings, binary DER bytes, or encoded data such as Base64 or hex.

**Add certificate chains**

Import an entire `CertChain` when related issuer and intermediate certificates should be kept together in the vault.

**Add PEM content**

Load PEM files containing one or more certificates and/or private keys, including encrypted PEM content when a password is supplied.

**Add PFX / PKCS12**

Add PFX data from a `Pfx` object, file, byte array, or encoded string, using the PFX password to import private-key material.

**Master password protection**

Use `MasterPassword` to protect access to private keys stored in the vault.

**Load and save XML**

Export the vault with `GetXml`, load it with `LoadXml` or `LoadXmlFile`, and persist it with `SaveXml`.

**Common pattern:** Create an `XmlCertVault`, set `MasterPassword` when the vault will contain private keys, add certificates or PFX/PEM material, then save the vault with `SaveXml` or keep the XML string from `GetXml`. Later, reload the same vault with `LoadXml` or `LoadXmlFile` and provide the same master password before using private keys.

**Security note:** Certificates are stored unencrypted, but private keys are stored using 256-bit AES encryption. The individual PFX passwords are also stored encrypted with the vault's `MasterPassword`, which is required to access any private keys contained in the XML vault.

## Object creation, unlocking and error handling

**Create/Dispose**

```c
HCkXmlCertVault instance = CkXmlCertVault_Create();
// ...
CkXmlCertVault_Dispose(instance);
```

`HCkXmlCertVault CkXmlCertVault_Create(void);`

Creates an instance of the HCkXmlCertVault object and returns a handle ("void \*" pointer). The handle is passed in the 1st argument for the functions listed on this page.

`void CkXmlCertVault_Dispose(HCkXmlCertVault handle);`

Objects created by calling CkXmlCertVault_Create must be freed by calling this method. A memory leak occurs if a handle is not disposed by calling this function. Also, any handle returned by a Chilkat "C" function must also be freed by the application by calling the appropriate Dispose method, such as CkXmlCertVault_Dispose.

Call `Global.UnlockBundle` once at the start of the program, before using this or any other Chilkat class. Any string unlocks a fully functional 30-day trial; a purchased unlock code is used in production. See `guide.md` for the exact code in C.

## Members common to every Chilkat class

Documented once per language in `common-members.md`; listed here so this page is self-contained.

| Property | Signature | Access | Meaning |
|---|---|---|---|
| `DebugLogFilePath` | `void CkXmlCertVault_getDebugLogFilePath(HCkXmlCertVault cHandle, HCkString retval); void CkXmlCertVault_putDebugLogFilePath(HCkXmlCertVault cHandle, const char *newVal); const char *CkXmlCertVault_debugLogFilePath(HCkXmlCertVault cHandle);` | read/write | If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. |
| `LastErrorHtml` | `void CkXmlCertVault_getLastErrorHtml(HCkXmlCertVault cHandle, HCkString retval); const char *CkXmlCertVault_lastErrorHtml(HCkXmlCertVault cHandle);` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `void CkXmlCertVault_getLastErrorText(HCkXmlCertVault cHandle, HCkString retval); const char *CkXmlCertVault_lastErrorText(HCkXmlCertVault cHandle);` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `void CkXmlCertVault_getLastErrorXml(HCkXmlCertVault cHandle, HCkString retval); const char *CkXmlCertVault_lastErrorXml(HCkXmlCertVault cHandle);` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `BOOL CkXmlCertVault_getLastMethodSuccess(HCkXmlCertVault cHandle); void CkXmlCertVault_putLastMethodSuccess(HCkXmlCertVault cHandle, BOOL newVal);` | read/write | Indicates the success or failure of the most recent method call: `TRUE` means success, `FALSE` means failure. |
| `Utf8` | `BOOL CkXmlCertVault_getUtf8(HCkXmlCertVault cHandle); void CkXmlCertVault_putUtf8(HCkXmlCertVault cHandle, BOOL newVal);` | read/write | When set to `TRUE`, all `const char *` arguments and return values are interpreted as UTF-8 strings. |
| `VerboseLogging` | `BOOL CkXmlCertVault_getVerboseLogging(HCkXmlCertVault cHandle); void CkXmlCertVault_putVerboseLogging(HCkXmlCertVault cHandle, BOOL newVal);` | read/write | If set to `TRUE`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `void CkXmlCertVault_getVersion(HCkXmlCertVault cHandle, HCkString retval); const char *CkXmlCertVault_version(HCkXmlCertVault cHandle);` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `MasterPassword` | property, read/write | `void CkXmlCertVault_getMasterPassword(HCkXmlCertVault cHandle, HCkString retval); void CkXmlCertVault_putMasterPassword(HCkXmlCertVault cHandle, const char *newVal); const char *CkXmlCertVault_masterPassword(HCkXmlCertVault cHandle);` |
| `AddCert` | method | `BOOL CkXmlCertVault_AddCert(HCkXmlCertVault cHandle, HCkCert cert);` |
| `AddCertChain` | method | `BOOL CkXmlCertVault_AddCertChain(HCkXmlCertVault cHandle, HCkCertChain certChain);` |
| `AddCertEncoded` | method | `BOOL CkXmlCertVault_AddCertEncoded(HCkXmlCertVault cHandle, const char *encodedBytes, const char *encoding);` |
| `AddCertFile` | method | `BOOL CkXmlCertVault_AddCertFile(HCkXmlCertVault cHandle, const char *path);` |
| `AddCertString` | method | `BOOL CkXmlCertVault_AddCertString(HCkXmlCertVault cHandle, const char *certData);` |
| `AddPemFile` | method | `BOOL CkXmlCertVault_AddPemFile(HCkXmlCertVault cHandle, const char *path, const char *password);` |
| `AddPfx` | method | `BOOL CkXmlCertVault_AddPfx(HCkXmlCertVault cHandle, HCkPfx pfx);` |
| `AddPfxEncoded` | method | `BOOL CkXmlCertVault_AddPfxEncoded(HCkXmlCertVault cHandle, const char *encodedBytes, const char *encoding, const char *password);` |
| `AddPfxFile` | method | `BOOL CkXmlCertVault_AddPfxFile(HCkXmlCertVault cHandle, const char *path, const char *password);` |
| `GetXml` | method | `BOOL CkXmlCertVault_GetXml(HCkXmlCertVault cHandle, HCkString outStr); const char *CkXmlCertVault_getXml(HCkXmlCertVault cHandle);` |
| `LoadXml` | method | `BOOL CkXmlCertVault_LoadXml(HCkXmlCertVault cHandle, const char *xml);` |
| `LoadXmlFile` | method | `BOOL CkXmlCertVault_LoadXmlFile(HCkXmlCertVault cHandle, const char *path);` |
| `SaveXml` | method | `BOOL CkXmlCertVault_SaveXml(HCkXmlCertVault cHandle, const char *path);` |

Deprecated members are listed at the end of this file with their replacements; do not use them in new code.

## Properties

### XmlCertVault.MasterPassword

`Chilkat 11.7.0 · c · XmlCertVault · MasterPassword · property · read/write · since 9.5.0.40`

```c
void CkXmlCertVault_getMasterPassword(HCkXmlCertVault cHandle, HCkString retval);
void CkXmlCertVault_putMasterPassword(HCkXmlCertVault cHandle, const char *newVal);
const char *CkXmlCertVault_masterPassword(HCkXmlCertVault cHandle);
```

The master password for the vault. Certificates are stored unencrypted, but private keys are stored 256-bit AES encrypted using the individual PFX passwords. The PFX passwords are stored 256-bit AES encrypted using the master password. The master password is required to acces any of the private keys stored within the XML vault.

## Methods

### XmlCertVault.AddCert

`Chilkat 11.7.0 · c · XmlCertVault · AddCert · method · since 9.5.0.40`

```c
BOOL CkXmlCertVault_AddCert(HCkXmlCertVault cHandle, HCkCert cert);
```

Adds a certificate to the XML vault.

Returns TRUE for success, FALSE for failure.

### XmlCertVault.AddCertChain

`Chilkat 11.7.0 · c · XmlCertVault · AddCertChain · method · since 9.5.0.40`

```c
BOOL CkXmlCertVault_AddCertChain(HCkXmlCertVault cHandle, HCkCertChain certChain);
```

Adds a chain of certificates to the XML vault.

Returns TRUE for success, FALSE for failure.

### XmlCertVault.AddCertEncoded

`Chilkat 11.7.0 · c · XmlCertVault · AddCertEncoded · method · since 9.5.0.40`

```c
BOOL CkXmlCertVault_AddCertEncoded(HCkXmlCertVault cHandle, const char *encodedBytes, const char *encoding);
```

Adds a certificate to the XML vault where certificate is passed directly from encoded bytes (such as Base64, Hex, etc.). The encoding is indicated by `encoding`.

Returns TRUE for success, FALSE for failure.

### XmlCertVault.AddCertFile

`Chilkat 11.7.0 · c · XmlCertVault · AddCertFile · method · since 9.5.0.40`

```c
BOOL CkXmlCertVault_AddCertFile(HCkXmlCertVault cHandle, const char *path);
```

Adds a certificate to the XML vault.

Returns TRUE for success, FALSE for failure.

### XmlCertVault.AddCertString

`Chilkat 11.7.0 · c · XmlCertVault · AddCertString · method · since 9.5.0.40`

```c
BOOL CkXmlCertVault_AddCertString(HCkXmlCertVault cHandle, const char *certData);
```

Adds a certificate from any string representation format such as PEM.

Returns TRUE for success, FALSE for failure.

### XmlCertVault.AddPemFile

`Chilkat 11.7.0 · c · XmlCertVault · AddPemFile · method · since 9.5.0.40`

```c
BOOL CkXmlCertVault_AddPemFile(HCkXmlCertVault cHandle, const char *path, const char *password);
```

Adds the contents of a PEM file to the XML vault. The PEM file may be encrypted, and it may contain one or more certificates and/or private keys. The password is optional and only required if the PEM file contains encrypted content that requires a password.

Returns TRUE for success, FALSE for failure.

### XmlCertVault.AddPfx

`Chilkat 11.7.0 · c · XmlCertVault · AddPfx · method · since 9.5.0.40`

```c
BOOL CkXmlCertVault_AddPfx(HCkXmlCertVault cHandle, HCkPfx pfx);
```

Adds a PFX (PKCS12) to the XML vault.

Returns TRUE for success, FALSE for failure.

### XmlCertVault.AddPfxEncoded

`Chilkat 11.7.0 · c · XmlCertVault · AddPfxEncoded · method`

```c
BOOL CkXmlCertVault_AddPfxEncoded(HCkXmlCertVault cHandle, const char *encodedBytes, const char *encoding, const char *password);
```

Adds a PFX to the XML vault where PFX is passed directly from encoded bytes (such as Base64, Hex, etc.). The encoding is indicated by `encoding`.

Returns TRUE for success, FALSE for failure.

### XmlCertVault.AddPfxFile

`Chilkat 11.7.0 · c · XmlCertVault · AddPfxFile · method · since 9.5.0.40`

```c
BOOL CkXmlCertVault_AddPfxFile(HCkXmlCertVault cHandle, const char *path, const char *password);
```

Adds a PFX file to the XML vault.

Returns TRUE for success, FALSE for failure.

### XmlCertVault.GetXml

`Chilkat 11.7.0 · c · XmlCertVault · GetXml · method · since 9.5.0.40`

```c
BOOL CkXmlCertVault_GetXml(HCkXmlCertVault cHandle, HCkString outStr);
const char *CkXmlCertVault_getXml(HCkXmlCertVault cHandle);
```

Returns the contents of the cert vault as an XML string.

Returns TRUE for success, FALSE for failure.

### XmlCertVault.LoadXml

`Chilkat 11.7.0 · c · XmlCertVault · LoadXml · method · since 9.5.0.40`

```c
BOOL CkXmlCertVault_LoadXml(HCkXmlCertVault cHandle, const char *xml);
```

Loads from an XML string.

Returns TRUE for success, FALSE for failure.

### XmlCertVault.LoadXmlFile

`Chilkat 11.7.0 · c · XmlCertVault · LoadXmlFile · method · since 9.5.0.40`

```c
BOOL CkXmlCertVault_LoadXmlFile(HCkXmlCertVault cHandle, const char *path);
```

Loads from an XML file.

Returns TRUE for success, FALSE for failure.

### XmlCertVault.SaveXml

`Chilkat 11.7.0 · c · XmlCertVault · SaveXml · method · since 9.5.0.40`

```c
BOOL CkXmlCertVault_SaveXml(HCkXmlCertVault cHandle, const char *path);
```

Saves the contents to an XML file.

Returns TRUE for success, FALSE for failure.

## Deprecated members — do not use in new code

| Member | Kind | Deprecated in | Use instead |
|---|---|---|---|
| `AddCertBinary` | method | before 11.6.1 | — |
| `AddPfxBinary` | method | before 11.6.1 | — |

## Related classes

[`Cert`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/c/classes/Cert.md), [`CertChain`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/c/classes/CertChain.md), [`Pfx`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/c/classes/Pfx.md)

