---
product: Chilkat
product_version: 11.7.0
language: b4x
language_label: B4X
class: XmlCertVault
class_name: ChilkatXmlCertVault
license: free
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/b4x_XmlCertVaultRef.html
---
# Chilkat XmlCertVault — B4X — v11.7.0

> Chilkat 11.7.0 · language=b4x · class=XmlCertVault (ChilkatXmlCertVault)
> 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/b4x/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

**Declare / Initialize / Dispose**

```visual-basic
Sub Process_Globals
    Private obj As ChilkatXmlCertVault
End Sub

' Call Initialize before first use -- typically in AppStart (B4J)
' or Activity_Create (B4A):
obj.Initialize                ' classes without events
obj.Initialize("evt")        ' classes with events: "evt" becomes the
                              ' prefix of event Subs such as evt_PercentDone
```

`Initialize / Initialize (EventName As String)`

Creates the underlying native Chilkat object. Classes that support events take an `EventName` argument: it becomes the prefix of the event Subs (`<EventName>_AbortCheck`, `<EventName>_PercentDone`, `<EventName>_ProgressInfo`); classes without events take no arguments. The native Chilkat library loads automatically on the first Initialize — from the APK on Android, or extracted from ChilkatB4J.jar on Windows/Linux/macOS.

`IsInitialized As Boolean`

`True` if `Initialize` has been called and the native object exists.

`Dispose`

Explicitly frees the underlying native object. Calling `Dispose` is optional — every ChilkatXmlCertVault is also freed automatically when garbage-collected — but is recommended for long-lived objects holding sockets, sessions, or large buffers. A disposed object can be re-Initialized.

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 B4X.

## 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` | `' read/write DebugLogFilePath As String` | 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` | `' read-only LastErrorHtml As String` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `' read-only LastErrorText As String` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `' read-only LastErrorXml As String` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `' read/write LastMethodSuccess As Boolean` | read/write | Indicates the success or failure of the most recent method call: `True` means success, `False` means failure. |
| `VerboseLogging` | `' read/write VerboseLogging As Boolean` | read/write | If set to `True`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `' read-only Version As String` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `MasterPassword` | property, read/write | `' read/write MasterPassword As String` |
| `AddCert` | method | `AddCert (cert As ChilkatCert) As Boolean` |
| `AddCertChain` | method | `AddCertChain (certChain As ChilkatCertChain) As Boolean` |
| `AddCertEncoded` | method | `AddCertEncoded (encodedBytes As String, encoding As String) As Boolean` |
| `AddCertFile` | method | `AddCertFile (path As String) As Boolean` |
| `AddCertString` | method | `AddCertString (certData As String) As Boolean` |
| `AddPemFile` | method | `AddPemFile (path As String, password As String) As Boolean` |
| `AddPfx` | method | `AddPfx (pfx As ChilkatPfx) As Boolean` |
| `AddPfxEncoded` | method | `AddPfxEncoded (encodedBytes As String, encoding As String, password As String) As Boolean` |
| `AddPfxFile` | method | `AddPfxFile (path As String, password As String) As Boolean` |
| `GetXml` | method | `GetXml As String` |
| `LoadXml` | method | `LoadXml (xml As String) As Boolean` |
| `LoadXmlFile` | method | `LoadXmlFile (path As String) As Boolean` |
| `SaveXml` | method | `SaveXml (path As String) As Boolean` |

## Properties

### XmlCertVault.MasterPassword

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

```visual-basic
' read/write

MasterPassword As String
```

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 · b4x · XmlCertVault · AddCert · method · since 9.5.0.40`

```visual-basic
AddCert (cert As ChilkatCert) As Boolean
```

Adds a certificate to the XML vault.

Returns True for success, False for failure.

### XmlCertVault.AddCertChain

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

```visual-basic
AddCertChain (certChain As ChilkatCertChain) As Boolean
```

Adds a chain of certificates to the XML vault.

Returns True for success, False for failure.

### XmlCertVault.AddCertEncoded

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

```visual-basic
AddCertEncoded (encodedBytes As String, encoding As String) As Boolean
```

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 · b4x · XmlCertVault · AddCertFile · method · since 9.5.0.40`

```visual-basic
AddCertFile (path As String) As Boolean
```

Adds a certificate to the XML vault.

Returns True for success, False for failure.

### XmlCertVault.AddCertString

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

```visual-basic
AddCertString (certData As String) As Boolean
```

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

Returns True for success, False for failure.

### XmlCertVault.AddPemFile

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

```visual-basic
AddPemFile (path As String, password As String) As Boolean
```

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 · b4x · XmlCertVault · AddPfx · method · since 9.5.0.40`

```visual-basic
AddPfx (pfx As ChilkatPfx) As Boolean
```

Adds a PFX (PKCS12) to the XML vault.

Returns True for success, False for failure.

### XmlCertVault.AddPfxEncoded

`Chilkat 11.7.0 · b4x · XmlCertVault · AddPfxEncoded · method`

```visual-basic
AddPfxEncoded (encodedBytes As String, encoding As String, password As String) As Boolean
```

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 · b4x · XmlCertVault · AddPfxFile · method · since 9.5.0.40`

```visual-basic
AddPfxFile (path As String, password As String) As Boolean
```

Adds a PFX file to the XML vault.

Returns True for success, False for failure.

### XmlCertVault.GetXml

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

```visual-basic
GetXml As String
```

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

Returns `Null` on failure

### XmlCertVault.LoadXml

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

```visual-basic
LoadXml (xml As String) As Boolean
```

Loads from an XML string.

Returns True for success, False for failure.

### XmlCertVault.LoadXmlFile

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

```visual-basic
LoadXmlFile (path As String) As Boolean
```

Loads from an XML file.

Returns True for success, False for failure.

### XmlCertVault.SaveXml

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

```visual-basic
SaveXml (path As String) As Boolean
```

Saves the contents to an XML file.

Returns True for success, False for failure.

## Related classes

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

