# Guardian help center home

<table data-view="cards" data-full-width="false"><thead><tr><th></th><th></th><th data-type="content-ref"></th><th data-type="content-ref"></th><th data-type="content-ref"></th><th data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Get started</strong></td><td><ul><li><a href="/get-started/get-familiar-with-the-guardian-ui">Get familiar with the Guardian UI</a></li><li><a href="/get-started/quickstart-process">Quickstart process</a></li><li><a href="/manage-devices/begin-device-provisioning#guardian-file-types-and-extensions">Guardian file types and extensions</a></li><li><a href="/get-started/terminology">Terminology</a></li></ul></td><td></td><td></td><td></td><td></td></tr><tr><td><strong>Manage systems</strong></td><td><ul><li><a href="/manage-systems/create-new-system">Create new system</a></li><li><a href="/manage-systems/manage-systems">Manage systems</a></li></ul></td><td></td><td></td><td></td><td></td></tr><tr><td><strong>Manage provisioning</strong></td><td><ul><li><a href="/manage-devices/begin-device-provisioning">Begin device provisioning</a></li><li><a href="/manage-devices/begin-device-provisioning#provisioning-methods">Provisioning methods</a></li><li><a href="/manage-devices/manage-device-provisioning">Manage device provisioning</a></li></ul></td><td></td><td></td><td></td><td></td></tr><tr><td><strong>Provision devices via UI</strong></td><td><ul><li><a href="/manage-devices/begin-device-provisioning#connected-provisioning-method">Connected device provisioning</a></li><li><a href="/manage-devices/begin-device-provisioning/provision-devices-using-api#disconnected-device-provisioning">Disconnected device provisioning</a></li></ul></td><td></td><td></td><td></td><td></td></tr><tr><td><strong>Provision devices via API</strong></td><td><ul><li><a href="/api-reference/api-overview">API overview</a></li><li><a href="/manage-devices/begin-device-provisioning/provision-devices-using-api#connected-device-provisioning">Connected device provisioning</a></li><li><a href="/manage-devices/begin-device-provisioning/provision-devices-using-api#disconnected-device-provisioning">Disconnected device provisioning</a></li><li><a href="/manage-devices/begin-device-provisioning/provision-devices-using-api#proxy-device-provisioning">Proxy device provisioning</a></li><li><a href="/api-reference/api-reference">API reference</a></li></ul></td><td></td><td></td><td></td><td></td></tr><tr><td><strong>Provision via command line</strong></td><td><ul><li><a href="/manage-devices/begin-device-provisioning/provision-devices-using-command-line#connected-device-provisioning">Connected device provisioning</a></li><li><a href="/manage-devices/begin-device-provisioning/provision-devices-using-command-line#disconnected-device-provisioning">Disconnected device provisioning</a></li><li><a href="/manage-devices/begin-device-provisioning/provision-devices-using-command-line#proxy-device-provisioning">Proxy device provisioning</a></li></ul></td><td></td><td></td><td></td><td></td></tr><tr><td><strong>Code examples</strong></td><td><ul><li><a href="/manage-devices/begin-device-provisioning/device-provisioning-code-examples#connected-device-provisioning-examples">Connected device provisioning</a></li><li><a href="/manage-devices/begin-device-provisioning/device-provisioning-code-examples#disconnected-provisioning-examples">Disconnected device provisioning</a></li><li><a href="/manage-devices/begin-device-provisioning/device-provisioning-code-examples#proxy-device-provisioning-examples">Proxy device provisioning</a></li></ul></td><td></td><td></td><td></td><td></td></tr><tr><td><strong>Administration</strong></td><td><ul><li><a href="/administration/user-roles-and-permissions">User roles and permissions</a></li></ul></td><td></td><td></td><td></td><td></td></tr></tbody></table>


# What is Guardian

Medcrypt's Guardian Platform provides PKI-based cryptographic security for medical devices, ensuring device authentication, secure communication, and regulatory compliance without disrupting performance. [Learn more about PKI and why it matters for medical devices](/overview/what-is-public-key-infrastructure-pki).

## **Guardian components**

Guardian consists of two main components:

* **Guardian Library**: Guardian Library runs on your devices to parse configuration profiles, request certificates from Guardian Cloud, and enable cryptographic functions like signing and encryption. Available for C++, C, Java, and more.
* **Guardian Cloud**: Cloud-based platform that processes certificate requests, enrolls devices into trust hierarchies, and generates certificates. This is the part of the Guardian platform formerly known as Overwatch.

## **Guardian core principles**

* All connections between devices should be secured
* Keys generated on the device never leave the device (including protection against data exfiltration methods)
* Keys should be rotatable as frequently as needed
* Key usage should be specific and isolated to particular operational contexts
* Security policy should be codified in signed configuration that drives operational usage

## **What Guardian provides:**

* Rapid deployment and seamless integration into new and existing systems
* Self-serve management through an intuitive web interface
* Device cryptographic identities with certificate-based authentication and automated lifecycle management
* Automated compliance reporting for FDA and other regulatory requirements
* Support for diverse hardware platforms, operating systems, and cryptographic libraries

## **What Guardian does:**

* Automated cryptographic key generation and management with unique keys for each device. Keys are FIPS 140-2 and FIPS 140-3 Level 3 compliant.
* Secure device-to-device communication (East-West protection)
* Secure device-to-cloud communication (North-South protection)
* Provisioning lifecycle management
* Support for memory-constrained and connectivity-limited devices
* Zero-trust security architecture implementation
* Legacy system protection without code modification
* Certificate lifecycle management (coming soon!)
* PKI operations

## **Common use cases:**

* Create segmented security zones across multi-device ecosystems
* Protect sensitive assets throughout the manufacturing process
* Establish trusted connections to cloud services
* Meet FDA cybersecurity requirements
* Implement zero-trust security architectures
* Manage cryptographic keys throughout device lifecycle
* Provide legacy system security without code modification


# Who should use Guardian?

Guardian is ideal for medical device manufacturers who need to:

**You need Guardian if you have:**

* Devices with technical constraints, including limited connectivity, memory, or processing power (e.g.,  pacemakers, insulin pumps, surgical instruments)
* Legacy systems that can't be easily modified
* Multiple devices that need to communicate securely
* Limited resources for managing PKI infrastructure
* Need to meet FDA cybersecurity requirements

**Common use cases:**

* Eliminate security vulnerabilities in device-to-device communication
* Streamline FDA compliance with automated reporting and documentation
* Establish trusted connections to cloud services
* Implement zero-trust security architectures
* Manage cryptographic keys throughout device lifecycle

## Teams

All of your teams benefit from using Guardian, as in these example initiatives.

* Product security engineers: Implementing zero-trust architectures.
* Software developers: Integrating security with minimal code changes.
* Product owners: Planning compliant security implementations
* Manufacturing teams: Implementing and streamlining device provisioning workflows

## Role and industry-specific solutions

No matter your role, Guardian has you covered.

#### Healthcare Delivery Organizations (HDOs)&#x20;

* **Inventory management:** Automatically detect and authenticate connected medical devices.
* **Vulnerability assessment:** Identify devices with security weaknesses.
* **Segmentation enforcement:** Ensure devices only connect to authorized systems.

#### Medical device manufacturers (MDMs)

* **FDA premarket requirements:** Meet FDA cybersecurity documentation requirements with automated reporting.
* **Secure design practices:** Build security into new devices from inception.
* **Legacy device management:** Secure already-cleared products without code modification.

#### Third-party service providers

* **Safe security updates in the field:** Simplified safe security updates by technicians
* **Remote monitoring:** Establish secure connections for remote service capabilities
* **Security validation:** Verify security measures without disrupting device operation


# What is Public Key Infrastructure (PKI)?

Public Key Infrastructure (PKI) is a critical framework for establishing and maintaining a secure digital environment. It enables secure communication, data integrity, and authentication through the use of encryption, digital certificates, and trusted authorities. In the context of medical devices, PKI plays a pivotal role in ensuring that devices operate securely and comply with regulatory requirements such as those enforced by the FDA.

PKI is a foundational technology for securing medical devices in an increasingly connected and regulated healthcare environment. By implementing PKI, manufacturers can address cybersecurity risks, ensure compliance with FDA regulations, and protect both patient safety and sensitive data. This approach not only reduces potential vulnerabilities but also enhances trust in the safety and reliability of medical devices deployed in clinical and home settings.

## **Why PKI matters for medical devices:**

1. **Data integrity and confidentiality:**
   * Medical devices often process sensitive patient information, which must be protected against unauthorized access or tampering.
   * PKI ensures data confidentiality through encryption and guarantees data integrity through digital signatures.
2. **Authentication:**
   * PKI enables strong authentication mechanisms for verifying the identity of devices, users, and software updates. This prevents unauthorized access and the installation of malicious firmware.
3. **Secure communication:**
   * Medical devices often communicate with other devices, cloud systems, or healthcare networks. PKI establishes secure communication channels using protocols like TLS (Transport Layer Security).
4. **Software and firmware integrity:**
   * PKI supports code-signing mechanisms to verify the authenticity and integrity of software and firmware updates, ensuring they come from trusted sources and have not been tampered with.
5. **Regulatory compliance:**
   * The FDA (Food and Drug Administration) emphasizes the importance of cybersecurity in medical devices as part of its regulatory framework.
   * PKI directly aligns with FDA guidance on secure design, risk management, and post-market monitoring, ensuring that medical devices meet required safety and performance standards.

### **PKI and FDA compliance:**

The FDA has outlined specific expectations and guidelines related to cybersecurity in medical devices:

* **Premarket cybersecurity guidance:**
  * Medical device manufacturers must address cybersecurity risks in the design phase and provide a security management plan, which often includes PKI-based solutions.
  * Submissions for FDA approval must include documentation of risk assessments, threat modeling, and the implementation of secure architectures like PKI.
* **Postmarket cybersecurity guidance:**
  * Devices must have mechanisms for secure updates and patches, supported by PKI to verify and validate these updates.
  * The FDA expects ongoing monitoring and timely response to cybersecurity threats, with PKI ensuring a trusted infrastructure to handle these updates.
* **Encryption and authentication standards:**
  * FDA guidance highlights the need for encryption and robust authentication, areas where PKI is a cornerstone technology.

### **How Guardian implements PKI:**

Guardian Platform makes enterprise-grade PKI accessible for medical device manufacturers by handling the complex cryptographic operations behind simple APIs. Rather than building and managing your own PKI infrastructure, Guardian provides:

* FIPS 140-2/3 Level 3 compliant key generation and management
* Automated certificate lifecycle management
* Secure device-to-device (East-West) and device-to-cloud (North-South) communication
* FDA-compliant provisioning workflows with automated reporting
* Support for memory-constrained devices through optimized certificate formats

This allows manufacturers to implement robust PKI security without the complexity and overhead of managing cryptographic infrastructure in-house.


# Security best practices

## **Overview**

Proper security implementation is critical when integrating Guardian into your medical devices. Follow these best practices to ensure Guardian file assets are properly protected and your device maintains security throughout its lifecycle.

## **Guardian file asset security**

Guardian uses three distinct groups of file assets, each with different security requirements:

* **System files** (formerly known as **Preloaded files (PLF):** These are the foundational files for your system. They must be loaded during manufacturing or signed software updates. They should always be write-protected and never updated directly.&#x20;
* **Provisioning package** (formerly known as  **Initial provisioning files (IPF):** This contains the bootstrap files for initial device setup, and is used for first-time device provisioning. These are a package of "marginally trusted" files that should only be distributed in controlled environments, preferably loaded during manufacturing and removed immediately after provisioning.&#x20;
* **Device files** (formerly known as **Provisioned files (PF):** These contain the unique identity and credentials for each device, and are generated or retrieved during the provisioning process.&#x20;

## TPM requirements

Guardian does not require a Trusted Platform Module (TPM), though TPMs can be used for additional security when available.

## Certificate formats

Guardian supports both standard X.509 certificates and Medcrypt proprietary certificates that are optimized for devices with memory constraints. The certificates you extract are normal X.509 certificates with standard expiration dates that can be inspected normally.

## File recovery scenarios

The impact of losing Guardian files depends on which files are lost and when:

* **During development:** You can regenerate keys and start over at any time before infrastructure involvement.
* **After initial upload:** Your `.mcpi` and `.mcpr` files must remain intact. Loss of `.mcpr` before provisioning completion means restarting the process.
* **After successful provisioning:** Your `.mcpi` file must remain intact. A `.mcp` file can be retrieved by re-submitting the same `.mcpr` file.

**Critical:** Loss of a .mcpi file at any time makes the keys and provisioned components unusable.

## **Disk encryption**

The purpose of disk encryption is for at-rest protection of file assets. Suitable methods for encrypting the disk should make use of an encryption key that is separately protected at rest (for example with a TPM).

## **Write protection**

#### **As root**

For devices where processes accessing Guardian file assets run as root, write protection can either be achieved with file attributes (if using a compatible file system/OS) or with read-only mounting of the disk. With either approach, the file assets should be owned by root (and have permissions u-w,g-w,o-w).

#### **As non-root**

For devices where processes accessing Guardian file assets do not run as root, write protection can be achieved by having system files be owned by root with file permissions u-w,g-w,o-w (and optionally using file attributes or read-only mounting). Since provisioning package and device files must be writable in some scenarios, they should be owned and written with a special "provisioning user" (and have permissions u+w,g-w,o-w).

## **Read protection**

#### **As root**

For devices where processes accessing Guardian file assets run as root, read protection can be achieved by setting file assets to have file permissions u-r,g-r,o-r.

#### **As non-root**

For devices where processes accessing Guardian file assets do not run as root, read protection can be achieved by creating a special "guardian-asset" group for the file assets to reside and setting file assets to have file permissions u+r,g+r,o-r. Processes needing to access these file assets must then be executed by a user that is in this group.

#### **Writing file assets (provisioning)**

Initial provisioning of a device is straightforward with device files being written to an appropriate path (and preferably the provisioning package being erased).

During reprovisioning, however, there will exist two sets of device files: the active set and the new set being generated. Particular care must be taken not to overwrite the active set during the provisioning process, thus usually necessitating that some sort of swapping strategy be employed (such as using symbolic links, environment variables, or remounting disks).

#### **Additional device security best practices**

Ensuring the security of keys is paramount, and they must be stored in memory areas immune to data exfiltration through methods like JTAG or similar techniques. It is crucial that private keys remain within the device and are not transferred off said device at any stage of its lifecycle.

## **Provisioning security considerations**

During initial provisioning, write the **device files** to appropriate paths and erase the **provisioning package** **files** immediately. For reprovisioning, use a swapping strategy (symbolic links, environment variables, or disk remounting) to avoid overwriting active files while generating new sets.

## **Device security fundamentals**

Store keys in memory areas immune to data exfiltration through JTAG or similar methods. Private keys must never leave the device at any stage of its lifecycle. Implement proper access controls and monitoring to detect unauthorized access attempts.


# Quickstart process

{% hint style="warning" %}
🚧 **Many of the self-service features are currently in development.**<br>

This topic takes you through creating a system and getting Guardian up and running through to device provisioning via the Guardian UI. If preferred, you can also use the [command line](/manage-devices/begin-device-provisioning#provision-via-the-command-line) or the [Guardian API](/manage-devices/begin-device-provisioning/provision-devices-using-api) to provision devices.
{% endhint %}

Guardian Cloud (formerly known as Overwatch) is Medcrypt's web-based platform for managing device provisioning and certificates.&#x20;

<details>

<summary>Step 1: <strong>Sign in</strong></summary>

1. **Check your email for an invitation** from your Medcrypt contact.
2. **Click the invitation link** in your email.
3. **Set up your password** using the secure link.
4. **Sign in** at the Guardian Cloud URL provided by Medcrypt.

</details>

<details>

<summary>Step 2: <strong>Get started</strong></summary>

{% hint style="warning" %}
🚧 This feature is currently in development.
{% endhint %}

### **Get started page**

This is your central hub for getting Guardian up and running quickly. Jump right into configuring your system by selecting a use case that matches your architecture, then follow the guided wizard to get your devices securely communicating.

**Choose your path:** Start by selecting a use case to configure your system and generate your system provisioning package. You'll use this package with the Guardian library on your device to generate its provisioning request (PR) and begin secure operations.&#x20;

**Everything you need at your fingertips:**

* [**Download Guardian library**](/get-started/quickstart-process/download-guardian-library-file)**:** Find the library that matches your platform, language, and/or architecture needs.
* **Quickstart guides:** Follow step-by-step walkthroughs for provisioning devices through the [Guardian UI](/get-started/quickstart-process) , [API](/manage-devices/begin-device-provisioning/provision-devices-using-api), or [command line](/manage-devices/begin-device-provisioning#provision-via-the-command-line).&#x20;
* **Security assessment:** Take our [cybersecurity maturity assessment](https://docs.google.com/forms/d/e/1FAIpQLSeZT4tpUYIynp4npQNdE50u0NCQNEBIgz6RCoeJoykiIRI__Q/viewform) to evaluate your current security posture, identify gaps, and receive a tailored roadmap from our FDA experts to strengthen your medical device security.&#x20;
* [**SBOM vulnerability management**](https://helm.docs.medcrypt.com/get-started/quickstart-process): Start a free trial of our comprehensive SBOM and vulnerability management tool, Helm.&#x20;
* Explore our [pre-market and post-market services](https://www.medcrypt.com/services/overview). We'd love to talk with you! Our comprehensive services have helped clients reduce FDA approval time from 180 to 45-60 days with a 100% approval rate across over 200 projects and 60 clients.

### **Get familiar with Guardian UI**

Navigate Guardian easily with the top navigation bar (profile, theme toggle, breadcrumbs) and sidebar access to key pages:&#x20;

* Systems: View system configurations, download provisioning packages, and view certificate trust chain (Root of Trust).
* [Provisioning](/manage-devices/begin-device-provisioning): For disconnected devices, upload a device provisioning request (PR) and download the device certified profile (CP). For connected devices, the PR will automatically be uploaded to Guardian, and the CP automatically sent to the device.
* [Devices](/manage-devices/manage-device-provisioning): Manage device provisioning via automatic provisioning or manual approval steps.
* [Downloads](/get-started/quickstart-process/download-guardian-library-file): Download Guardian library
* Help: Check out our extensive help center or contact us for support.

</details>

<details>

<summary>Step 3: <strong>Create your first system</strong></summary>

{% hint style="warning" %}
🚧 This feature is currently in development.
{% endhint %}

There are two ways to create and start configuring your new system:

* Select a use case from the **Get started** page.  This displays when you first sign in, but if you've closed it, click the **Get started** item in the sidebar.
* Click the **Systems** item in the sidebar, then click **Add new system**. This will launch the [system creation wizard](/manage-systems/create-new-system).  If you need a custom integration not covered by these use cases, [contact support](mailto:support@medcrypt.co).

</details>

<details>

<summary>Step 4: <strong>Configure your system</strong></summary>

{% hint style="warning" %}
🚧 This feature is currently in development.
{% endhint %}

1. After selecting a use case in the system creation wizard, you will be automatically moved to the next step where you can configure your system.
2. Provide the system details, then click **Continue**. These will vary depending on the use case selected.
3. If you're not ready yet, you can always click **Save & continue later**. You can then access your system at any time from the **Systems** item in the sidebar.
4. In the next step, [select the Guardian library file](/get-started/quickstart-process/download-guardian-library-file) that meets your needs. You can filter by language, platform, or architecture. Download your file, then click **Continue**.
5. In the following step, you can view and export security certificates. This is an optional step. Click **Continue**.
6. In the final step, you can download the provisioning package for your system. You'll put this file in the **Guardian Library** file path that you defined. This will generate a provisioning request (PR), which will be sent to the Guardian server. Behind the scenes, we're creating the Root of Trust (RoT), HSM, and everything else you will need to get your devices up and running. Note that this could take some time, so we will notify you via email as soon as your provisioning package is ready for download.&#x20;

</details>

<details>

<summary>Step 5: Download Guardian library if you haven't already</summary>

{% hint style="warning" %}
🚧 This feature is currently in development.
{% endhint %}

You can [download your Guardian library](/get-started/quickstart-process/download-guardian-library-file) from the Downloads item on the sidebar if you didn't do so during system configuration, or prefer to start with the library.&#x20;

</details>

<details>

<summary>Step 6: Download system provisioning package</summary>

{% hint style="warning" %}
🚧 This feature is currently in development.
{% endhint %}

1. After receiving your email that your provisioning package is ready, click **Systems** to view all systems and their current status.&#x20;
2. Click the **Provisioning package** link on your system. Any system that has an available provisioning package will show a **Package ready** badge, which you can also click to view the provisioning package.
3. Click **Download** on the provisioning package.&#x20;

</details>

<details>

<summary>Step 6a: Extract PR from device (disconnected devices only)</summary>

Field technician extracts the provisioning request ( `.mcpr` file) generated by the device.

</details>

<details>

<summary>Step 6b: Upload PR into Guardian Cloud  (disconnected devices only)</summary>

1. Click the **Provisioning** item in the sidebar.&#x20;
2. Click the **Begin provisioning** button. This will prompt you to upload a provisioning request. This is an `.mcpr` file.&#x20;

</details>

<details>

<summary>Step 7: Monitor and approve PRs</summary>

All PRs, regardless of the method in which they were sent to Guardian Cloud, will appear in [Devices](/manage-devices/manage-device-provisioning) page for approval/processing workflow

* **Systems with automatic approval:** Guardian will automatically move device PRs through the approval process, then send each device's certified profile (CP) directly to the device.
* **Systems with manual approval:** Your team will manually approve or reject, then manually complete provisioning.&#x20;

</details>

<details>

<summary><strong>Step 7a: Complete provisioning (connected devices only)</strong></summary>

For both automatic and manual approval, the CP is automatically downloaded from Guardian and automatically installed on the device, then the device is automatically marked as **Provisioned** in Guardian.

For connected devices, this is the last step.

</details>

<details>

<summary>Step 8: <strong>Download profile (disconnected devices only)</strong> </summary>

When the provisioning request has been processed, you'll be prompted to download the certified profile or CP ( `.mcp` file) on the [Provisioning](/manage-devices/begin-device-provisioning) page.&#x20;

</details>

<details>

<summary><strong>Step 8a: Upload CP to device (disconnected devices only)</strong></summary>

1. CP is manually installed on the device.&#x20;
2. Click **Complete provisioning** to mark it as **Provisioned** in Guardian.

</details>

## Optional steps

<details>

<summary>View and export Root of Trust certificates </summary>

{% hint style="warning" %}
🚧 This feature is currently in development.
{% endhint %}

1. After creating a new system, click **Systems** on the sidebar.
2. Click the **Certificates** link on the system. This will display the Root of Trust (RoT) certificates (root and intermediate level). &#x20;
3. Click any root or intermediate certificate to expand all of its child certificates. Refer to [Manage Root of Trust certificates](/manage-systems/manage-certificate-trust-chain) for more information.
4. Click each certificate card to view its details. You can also search on certificate common name and filter by certificate level.
5. Click **Export** on each certificate you want to export. If you want to export a file for each of the certificates, click **Export all**. This will only export the filtered results.

</details>

<details>

<summary>View and export device-level certificates</summary>

{% hint style="warning" %}
🚧 This feature is currently in development.
{% endhint %}

1. Click **Devices** on the sidebar.
2. Click the **Certificates** tab.
3. Click any certificate to view its children. Refer to [Manage certificates](/manage-devices/manage-certificates) for more information.
4. Click each certificate card to view its details. You can also search on certificate common name and filter by certificate level.
5. Click **Export** on each certificate you want to export. If you want to export a file for each of the certificates, click **Export all**. This will only export the filtered results.

</details>


# Download Guardian library file

{% hint style="warning" %}
🚧 This feature is currently in development.
{% endhint %}

Download our **Guardian Library** files for your preferred language, platform, and architecture.

## What is Guardian library?

Guardian Library is a lightweight software package that integrates into your medical devices to provide cryptographic security capabilities. The library acts as the bridge between your device and the Guardian Cloud platform, handling all the complex security operations behind a simple API. It handles key generation, certificate requests, and secure connections without requiring complex cryptographic expertise from your development team.

### What Guardian library does

* **Generates cryptographic keys** directly on your device for maximum security
* **Requests and manages certificates** from Guardian Cloud automatically
* **Provides easy-to-use APIs** for device authentication, secure communication, and data signing
* **Handles provisioning workflows** including initial setup and reprovisioning
* **Manages the complete certificate lifecycle** without manual intervention

### How it works

After integration, Guardian Library reads a secure configuration profile and automatically requests certificates from Guardian Cloud. Once your device is provisioned, the library enables secure device-to-device communication (East-West) and secure connections to cloud services (North-South) using industry-standard cryptographic protocols.

You can download your Guardian Library file either during your system creation and configuration, or at any time from the **Downloads** item in the sidebar.

### Download Guardian library files

1. If you are creating a new system, you can download the Guardian library as a part of this setup process. If not, click the **Downloads** item on the sidebar.
2. Select the version and configuration that meets your needs, then click **Download**.

#### Filter files

* **Version:** Select the latest version or a previous version
* **Status:**&#x20;
  * Actively supported: Current versions received regular updates and full support
  * Beta: Pre-release versions
  * Alpha: Early access versions
  * Nearing end-of-support: These versions will not be supported after the specified date.
  * No longer supported (EOS): Legacy versions that are no longer updated or supported.
* **Language:** C, C++, C#, Java, and Python
* **Platform:** Windows, Linux, QNX, FreeBSD
* **Architecture:** x86, x86\_64, ARM, aarch64

### Verify file integrity

Checksums are provided for file integrity verification. Hover over the checksum to display the copy icon, then copy the value for verification.


# Provision your first device

## Overview

This tutorial uses a combination of command line and UI steps for quick device provisioning. For comprehensive coverage of all provisioning methods, see \[Begin device provisioning], which covers command line, UI, and API approaches in detail.

### Prerequisites

Make sure you have the following:

* Guardian Cloud account
* Provisioning package for the system
* A test device or the mcguard\_provision utility
* Basic device information (component name, system ID, hardware ID)

### Steps to provision

<details>

<summary>Step 1: Generate a provisioning request (command line)</summary>

On your device or using mcguard\_provision:

```bash
bash# Generate provisioning request offline./mcguard_provision \  --mode provision \  --component test_component \  --system test_system \  --hardware-id test_device_001 \  --offline \  /path/to/initial/provisioning/profile
```

This creates two files:

* `test_component_test_system_test_device_001.mcpr` (can be uploaded)
* `test_component_test_system_test_device_001.mcpi` (keep secure, never upload)

</details>

<details>

<summary>Step 2: Upload provisioning request to Guardian Cloud</summary>

1. Sign in to **Guardian Cloud**
2. Click **Provisioning** item on the sidebar
3. Click the **Upload provisioning request** button.
4. Select your `.mcpr` file.
5. Verify the device information shown
6. Click **Submit.**

</details>

<details>

<summary>Step 3: Download the system provisioning package</summary>

1. Wait for processing (usually 1-2 minutes)
2. Check the status in your dashboard
3. Download the .mcp file when ready
4. Transfer the .mcp file back to your device

</details>


# Get familiar with the Guardian UI

## Navigation

### **Top navigation bar**

{% hint style="warning" %}
🚧 This feature is currently in development.
{% endhint %}

In the top navigation bar, you can access your profile, as well as sign out of Guardian. This also contains the breadcrumbs, from which you can select a system name, also known as a system definition, as well as understand at a glance where you are in Guardian. You can also click the sun/moon icon to change themes.

## **Breadcrumbs**

{% hint style="warning" %}
🚧 This feature is currently in development.
{% endhint %}

Each Guardian page has a breadcrumb trail so that you know exactly where you are. All breadcrumb trails start with **Home /**. Depending on the UI page you are on, the breadcrumb also provides quick selections, such as selecting a system.

### **URLs**

{% hint style="warning" %}
🚧 This feature is currently in development.
{% endhint %}

Share deep links to particular Guardian pages with colleagues.

## **Sidebar**

You can access any main page in the sidebar, including:

* **Systems (coming soon):** Shows your partially and fully configured systems. You can download the system provisioning package from here, as well as view and export certificates. This has two tabs:
  * [**Provisioning package tab**](/manage-devices/manage-device-provisioning)
  * [**Certificates tab**](/manage-systems/manage-certificate-trust-chain)
* **Provisioning:** Upload a PR for each device, then download the Certified Profile. Although both **Provisioning** and **Devices** show device provisioning status, Devices is the newer page, enabling you to manually or automatically manage device provisioning, as well as export a device provisioning report.&#x20;
* **Devices:** Shows your organization's device provisioning activity.  You cannot currently upload PRs for devices yet. This page replaces the concept of the Certified Profile with that of provisioning package, which is a zip of all files you will need to install the package on your device. This has two tabs:
  * [**Provisioning tab**](/manage-devices/manage-device-provisioning)
  * [**Certificates tab (coming soon)**](/manage-devices/manage-certificates)
* **Downloads (coming soon):** Download the Guardian library that meets your platform and architecture needs.
* **Help:** Access this Help center, enter a support ticket, view the changelog, and check your product versioning.&#x20;
  * **Get started page**
* **Administration (coming soon):** Manage [user access](/administration/user-roles-and-permissions) to your systems.

### Filters

{% hint style="warning" %}
🚧 This feature is currently in development.
{% endhint %}

Click the **Filters** drop-down above lists to quickly drill down to exactly what you need.&#x20;

## Themes

{% hint style="warning" %}
🚧 This feature is currently in development.
{% endhint %}

Choose between our dark or light theme. To switch themes, click the sun/moon icon in the main navigation bar.

## **Tables**

### **Customizable data display**

{% hint style="warning" %}
🚧 This feature is currently in development.
{% endhint %}

Take control of how you view and interact with data. You can adjust table column visibility, perform multi-sorts, and choose your preferred display density.

* **Content refresh setting:** Take charge of your data updates by setting auto-refresh intervals or turning it off entirely. You can also refresh manually refresh.&#x20;
* **Pagination:** Navigate large datasets with ease using our new pagination feature, ensuring you don’t lose your place.
* **Hide or show columns:** Click the **Columns** link to toggle on/off specific columns. If you want to hide a particular column that is already displayed, you can also hover over each column header to display a ... icon. Click this, then select **Hide column**.
* **Customizable columns:** Tailor your tables to display exactly what you need. Use the **Columns** link to show or hide specific columns and hover over column headers to drag and drop them into your preferred order with the **…** icon.
* **Change column order:** Hover over each column header to display a ... icon. Click this, then select Move right or Move left to order columns exactly how they work best for you.
* **Column sorting:** Sort columns in alphabetic or reverse-alphabetic order. Hover over each column header to display a ... icon. Click this, then select **Sort A-Z** or **Sort Z-A**.
* **Flexible display density:** Optimize your view by selecting a compact or expanded display mode and adjusting the number of rows per page to suit your preferences.
* **Date picker:** Gain precise control over date filtering with options for absolute/relative dates, custom ranges, and multi-month views.

### Why can't I see some columns?

If you don't see particular columns, that means that they are currently hidden by default. You can customize your view to show only the data you want, nothing you don't — enabling you to stay focused on what matters most. Click the **Columns** link in the top of the table to see which columns are available, then toggle on/off columns to display only the ones you need.&#x20;

## Help

{% hint style="warning" %}
🚧 This feature is currently in development.
{% endhint %}

* **Get started:** Click the path that best describes your needs to get started quickly.
* **Documentation**: Get started or get unstuck quickly right here!
* **About:** Click **Help > About** in the sidebar to view version information. If you're using Guardian in your QMS, this will ensure that you have the correct versions for each Guardian module (see our [**changelog version note**](/updates/changelog) to understand versioning).&#x20;
* **Contact us:** We are always here to help get you unstuck!&#x20;


# Terminology

## Identity & configuration terms

**Component handle:** A specific device or piece of a system. In the Guardian ecosystem, a component is defined by a human-readable name, the certificates and keys it provides, and the operations it can perform.

**Hardware ID:** A unique identifier to the specific instance of a component, commonly set to the device's serial number. The same hardware ID is used throughout the lifetime of the component, including through any reprovision operations.

**System:** A grouping of components, also known as a system definition. All provisioning requests for components in this system will either go through a manual or automatic approval, depending on your system setting.

## **Process terms:**

### **Approval workflows**

* **Automatic approval:** System setting where provisioning requests are processed automatically without human intervention.
* **Manual approval:** System setting where provisioning requests require human review and approval before processing.

### **Device provisioning**&#x20;

**Provisioning:** The process of securely establishing device identity and configuring cryptographic credentials for secure communication.

**Reprovisioning:** Updating an already-provisioned device with new certificates or configuration while maintaining the same hardware identity.

**Provisioning methods**

* **Connected provisioning:** Provisioning workflow for devices with network connectivity that can communicate directly with Guardian Cloud.
* **Disconnected provisioning:** Provisioning workflow for devices without network connectivity where provisioning requests must be manually transferred via files.
* **Proxy provisioning:** Using a connected device to handle provisioning requests for disconnected devices that cannot communicate directly with Guardian Cloud.

## **Cryptography & security terms**

**Certificate Authority (CA):** The trusted entity that issues digital certificates. In Guardian deployments, Guardian Cloud can serve as a CA, though Guardian also works with other certificate authorities.

**Certificate Revocation List (CRL):** A list of certificates that have been revoked before their expiration date and should no longer be trusted.

**Certificate Signing Request (CSR):** A standardized message containing a device's public key and identity information, sent to Guardian Cloud to request a digital certificate.

**PKI (Public Key Infrastructure):** The cryptographic framework that Guardian uses to establish and maintain secure digital identities through certificates and keys.

**Trust anchor:** The foundational certificates used to validate other certificates in the system. Stored in the `TrustStore` file.

## Guardian Platform terms

**Platform components:**

* **Guardian Cloud:** Cloud-based platform that processes certificate requests, enrolls devices into trust hierarchies, and generates certificates.
* **Guardian Library:** Software library that runs on your devices to parse configuration profiles, request certificates from Guardian Cloud, and enable cryptographic functions.

### Guardian file types and extensions

Guardian uses several file types with specific extensions during the provisioning process:

**Provision Request:** File used for transmitting information including public keys to the Guardian Cloud backend. This contains the Certificate Signing Requests (CSRs) sent to Guardian Cloud. Extension: `.mcpr`

**TrustStore:** Trust anchors for the Guardian platform. Extension: `.mcts`

**Profile files:**

1. **Certified Profile to be Provisioned:** Signed instructions and configuration for the Guardian library and provisioning operations. This is the initial profile template for this device type created during the provisioning process. Extension: `.mcpp`
2. **Certified Profile:** Signed instructions and configuration for the Guardian library run and reprovisioning operations. This is the final device profile created during the provisioning process. Extension: `.mcp`

**Identity files:**&#x20;

1. **Private Identity to be Provisioned:** Key material for initial provisioning operations and connections. This is the initial private identity template. Extension: `.mcpip`
2. **Private Identity:** Key material for reprovisioning and run operations and connections. This is the final private identity file, which contains the private keys that stay on the device. Extension: `.mcpi`


# Create new system

{% hint style="warning" %}
🚧 This feature is currently in development.
{% endhint %}

## Device provisioning overview

After selecting your use case and configuring your system details, you'll choose the Guardian library that best fits your needs. Guardian Library runs on your devices to parse configuration profiles, request certificates from Guardian Cloud, and enable cryptographic functions like signing and encryption. It is available for several platforms, architectures and languages.

1. **System setup:** Create and configure your system with components in Guardian
2. **Library setup:** Download Guardian Library for your platform
3. **Bootstrap preparation:** Medcrypt creates your system's provisioning package, which includes your certificate trust chain (Root of Trust)
4. **Package download:** Download the provisioning package for your system
5. **Identity generation:** Device uses Guardian Library + provisioning package to generate a provisioning request (PR). The device keeps the private key (`.mcpi` file), which never leaves the device.

The system creation wizard covers **steps 1-4** of this process. After completing the wizard, you'll move on to step 5 where your device generates its provisioning request.

## Create and configure new system

There are two ways to create and start configuring your new system:

* Select a use case from the **Get started** page.  This displays when you first sign in, but if you've closed it, click the **Get started** item in the **Help** section of the sidebar.
* Click the **Systems** item in the sidebar, then click **Add new system**.&#x20;

**Either of these methods will launch the system creation wizard:**

1. In the first step of the system creation wizard, select a use case. You will be automatically moved to the next step where you can configure your system. Guardian currently provides the following out-of-the-box use cases.&#x20;
   * **Client-cloud:** Our client-cloud configuration enables secure communication between medical devices and cloud services with automated certificate provisioning and end-to-end encryption.
   * **Client-server:** Our client-server configuration provides robust encryption for traditional client-server architectures with mutual certificate-based authentication and lifecycle management.
   * **DDS configuration:** Our Secure Data Distribution Service (DDS) configuration provides certificate-based authentication for real-time data communication.
   * If you need a custom integration not covered by these use cases, [contact support](mailto:support@medcrypt.co).
2. Provide the system details in the next step, then click **Continue**. These details will vary depending on the use case selected.
3. If you're not ready yet, you can always click **Save & continue later**. You can then access your system at any time from the **Systems** item in the sidebar.
4. In the next step, [select the Guardian library file](/get-started/quickstart-process/download-guardian-library-file) that meets your needs. You can filter by language, platform, or architecture. Download your file, then click **Continue**.&#x20;
5. You'll see a message that we're generating your provisioning package for your system, including the certificate trust chain. We'll send you an email when your provisioning package is ready for download.
6. Click **Close** to close the wizard. This will display the **Systems** page. You'll see that there is a **Generating...** indicator on your new system's card.&#x20;
7. After you receive your email that your provisioning package is ready, you'll see a **Download package** badge on the system card, and the **Provisioning package** link on the system card will be enabled.&#x20;


# Manage systems

{% hint style="warning" %}
🚧 This feature is currently in development.
{% endhint %}

## **Overview**

The Systems page provides visibility into your various systems, as well as access to essential system management tools, including:&#x20;

* **Download system provisioning packages** Access and download provisioning packages directly from the Guardian Cloud UI for streamlined device setup processes.
* **View and export Root of Trust certificates** Manage your PKI infrastructure by viewing and exporting root and intermediate level certificates, providing complete oversight of your certificate management.

## Manage systems

1. Click the **Systems** item in the sidebar. This will display your available systems.&#x20;
2. Click the Provisioning packages link on the system card. This will display the **Provisioning packages** tab.
3. Click **Download** on the provisioning package card to download that system provisioning package.
4. Click the **Certificates** tab. This will display the root and intermediate certificate trust chain for the selected system.&#x20;
5. Click any certificate to view its details.

### Systems cards

Each system card displays the following information:

* **System name:** This displays the name of the system, also known as the system definition.
* **Last updated:** This reflects the date the system configuration was last updated.&#x20;
* **Approval type:** This is the device provisioning approval workflow for this system (**Automatic** or **Manual**).
* **Provisioning source:** This is the source by which your devices are provisioning (**Cloud** or **Appliance**).
* **Components:** The components in your system.

#### System status badges:

* **Complete configuration:** If you've started configuring a system that is still in draft mode, you can click this badge or link to finish your configuration.
* **Download package:** When your system provisioning package is ready, you can click this badge or the **Provisioning package** link to download the package.
* **Provisioned:** If all devices in your system are provisioned, this badge will display. You can still download provisioning packages or manage the certificate trust chain.

### Provisioning packages

The **Provisioning packages** tab displays if you click the system name or **Provisioning package** link on the system card. If a system's provisioning package is ready for download, the **Download** button will be enabled.

### Certificates: Manage trust chain

Click the [Certificates](/manage-systems/manage-certificate-trust-chain) tab on any system card to manage root and intermediate (Root of Trust) certificates for your system.&#x20;


# Manage certificate trust chain

{% hint style="warning" %}
🚧 This feature is currently in development.
{% endhint %}

You can manage the certificate trust chain of root and intermediate certificates (Root of Trust) for your system.&#x20;

## Manage systems

1. Click the **Systems** item in the sidebar. This will display your available systems.&#x20;
2. Click the **Certificates** link on a system card. This will display the root and intermediate certificate trust chain for the selected system.&#x20;
3. Click any certificate to view its details.

### Certificates

Each certificate card displays on the right under the filter bar. By default, the first certificate in the list is selected. The current selection is indicated by a blue background and a blue selection bar on the far left of the card.&#x20;

### Certificate types

Guardian can use two types of certificates to secure devices:&#x20;

* **Standard x.509 certificates:** This is the certificate type used in our out-of-the-box system configurations.
* **Medcrypt-proprietary certificates:** We also can provide our proprietary certificates that are specifically designed for medtech use cases such as memory constraints.

### Certificate statuses

* **Pending validation:** This certificate has not yet been validated.
* **Active:** This certificate is active and is not nearing expiration.
* **Expired:** This certificate has expired and needs to be replaced.
* **Expires (timeframe):** This certificate is nearing its expiration date and should be replaced soon. It is currently still active. It indicates the number of days, weeks, or months until a certificate expires. Any certificate that expires in under 6 months will display this status.
* **Suspended:** This certificate has been suspended.
* **Revoked:** This certificate has been revoked. View the certificate details to see the reason for revocation.

### Certificate details

All certificates have standard x.509 fields. The exception is for device-level certificates, which have additional system details, provisioning details, and a **Medcrypt certificate attributes** section for context.&#x20;

**View certificate details and children**

1. Click any certificate to view its details. You can click the certificate card itself or its details icon.&#x20;
2. Root and intermediate certificates that have children will have a drop-down arrow. You can click each arrow to expand certificates individually or click the **expand all** icon to expand all parent certificates automatically.

<details>

<summary><strong>System details</strong></summary>

* **System name:** This is the system definition. It will also be referred to as system.
* **System instance name:** This is a particular instance of the system name.
* **Component name:** This is a component in the system instance.
* **Component instance ID:** This is the unique ID for a component.
* **Device HW ID:** This is the unique ID for a device.&#x20;
* **System instance ID:**
* **Component instance ID:** This is the unique ID for a component.
* **Component instance created on:** This is when the component instance was created.

</details>

<details>

<summary><strong>Provisioning details</strong></summary>

* **Provisioning status:** This shows the provisioning status of the PR. Statuses will depend on your system's defined approval type.
* **Approved on / by:** This is the date the provisioning request was approved, as well as whether it was automatically approved (System) or manually approved (user name).
* **Rejected on / by:** This is the date the provisioning request was rejected, as well as who rejected it.
* **Error code:** For systems using the automatic approval workflow, this will display a particular error code. Refer to [troubleshooting device provisioning](/manage-devices/manage-device-provisioning#troubleshooting) for more information.
* **Provisioned on / by:** This is the date the device provisioning was completed, as well as who provisioned it.

</details>

<details>

<summary><strong>Identity</strong></summary>

* Common name (CN)
* Organization name (O)
* Subject alt name (SAN): This is only shown for device-level certificates

</details>

<details>

<summary><strong>Status &#x26; validity</strong></summary>

* **Status:** This indicates the current status of a certificate.
* Not before: This also shows the date and relative time until the certificate is valid.
* Not after: This also shows the relative time until the certificate is no longer valid. If the certificate has expired, this shows the time elapsed, such as (x days ago).
* Validity period
* **Revoked on / by:** This is the date when the certificate was revoked and who it was revoked by.
* **Revocation reason:** This shows the reason the certificate was revoked.

</details>

<details>

<summary><strong>Security</strong></summary>

* TLS pinning
* Key type
* Signature algorithm

</details>

<details>

<summary><strong>Additional identity information</strong></summary>

* Organizational unit (OU)
* Email address (E)

</details>

<details>

<summary><strong>Location</strong></summary>

* Country (C)
* State/Province (ST or S)
* Locality/City (L)

</details>

#### Technical details section

<details>

<summary><strong>Key usage</strong></summary>

* Critical
* Permitted uses
* Serial number

</details>

<details>

<summary><strong>Basic constraints</strong></summary>

* Critical
* Certificate authority
* Path length constraint

</details>

<details>

<summary>Certificate identifiers</summary>

* Serial number
* Thumbprint
* Authority key identifier
* Subject key identifier

</details>

<details>

<summary><strong>Extended validation</strong></summary>

* CRL distribution points

</details>

### Export certificates

#### Export all certificates

You can export all certificates or filter down to a subset, then export. This will export a zip file containing a .PEM file for each certificate.

#### Export individual certificate

1. Click any certificate to view its details, as well as available actions. This will display the **Certificate details** section.
2. Click the **Export action** link. This will export a .PEM file for this certificate.

### Revoke certificates

Depending on the certificate level, you will have different revoke capabilities.&#x20;

1. Click any certificate to view its details, as well as available actions. This will display the **Certificate details** section.
2. Click the **Revoke certificate action** in the **Certificate details** section.&#x20;
3. In the respective confirmation panel, review the details for each certificate you are revoking.&#x20;
4. For root or intermediate certificates, specify the revocation reason. For device-level certificates, you can specify one revocation reason for all or individual revocation reasons for each certificate.&#x20;

### Filter certificates

All matching items will have a blue highlight background. If root or intermediate certificates are returned, their children are also returned to provide context. These are only highlighted if the child matches the search and filters applied.

### Search or filter certificates

**Search box**

In the search box drop-down, you can select **All certificates** or a certificate level, as well as search on the certificate common name.&#x20;

**Filter panel**

Click the **Filters** drop-down to filter on system, device, and certificate information.

<details>

<summary>System details</summary>

* **System name:** Select the main system to view. This is also known as the system definition.
* **System instance:** Select one or more system instances to view.
* **Component name:** Select one or more components to view.
* **Device hardware ID:** Specify a particular device hardware ID to filter on.

</details>

<details>

<summary><strong>Provisioning details</strong></summary>

* Toggle to view current provisioning status for all devices or all statuses the devices have moved through.
* **Provisioning status:** Select one or more provisioning status(es). The available statuses will depend on the approval type of the system you are currently viewing.
* **Provisioned on:** Select a quick timeframe date filter or provide a date range to view devices that moved to the **Provisioned** status during that time.
* **Approved on:** Select a quick timeframe date filter or provide a date range to view devices that moved to the **Approved** status during that time.
* **Rejected on:** Select a quick timeframe date filter or provide a date range to view devices that moved to the **Rejected** status during that time.

</details>

<details>

<summary>Certificate details</summary>

You can filter on root and intermediate certificates in their respective sections.&#x20;

* **Certificate status:** Select one or more provisioning status(es) for each certificate type you want to filter on.&#x20;
* **Expires on:** Select a date range to view which certificates will expire during that time.
* **Revocation reason**: Select one or more revocation reasons to filter on. This filter conditionally displays if you select the **Revoked** certificate status.
* **Revoked on:** Select a date range to view which certificates were revoked during that time. This filter conditionally displays if you select the **Revoked** certificate status.

</details>

## Change date formatting

By default, device provisioning data is displayed in UTC time and in **dd mmm yyyy** format. You can change this to display ISO format and/or to show dates in your local time.

1. To change the date formatting, click the **Settings** drop-down in the toolba&#x72;**.**
2. Toggle the respective date settings, which will automatically apply.

## FAQ

#### How will we know when certificates expire?

You can filter on certificate status and expiration date, as well as view details for any certificate.&#x20;


# Understand device provisioning

{% hint style="success" %}
Regardless of which provisioning method you choose, follow our [Security best practices ](/overview/security-best-practices)for proper file handling and device security.
{% endhint %}

## Device provisioning overview

Device provisioning is fundamental to Guardian's security model. Device provisioning is the process where a medical device establishes its cryptographic identity. Think of it as giving your device a secure "passport" that proves who it is and allows it to communicate securely with other devices and systems.&#x20;

### **Methods for device provisioning:**

Guardian supports several device provisioning methods:

* [Provision using UI](/manage-devices/begin-device-provisioning)
* [Provision using Guardian API](/manage-devices/begin-device-provisioning/provision-devices-using-api)
* [Provision using command line](/manage-devices/begin-device-provisioning#provision-via-the-command-line)&#x20;

### **Device provisioning steps**

1. **System setup:** Create and configure your system with components in Guardian
2. **Library setup:** Download Guardian Library for your platform
3. **Bootstrap preparation:** Medcrypt creates your system's provisioning package
4. **Package download:** Download the provisioning package for your system
5. **Identity generation:** Device uses Guardian Library + provisioning package to generate Provisioning Request (PR). The device keeps the private key **(.mcpi** file), which never leaves the device.
6. **Request submission:** Submit PR (**.mcpr** file) via connected or disconnected method:
   * **Connected:** Device automatically sends PR to Guardian Cloud, where it displays on the Devices page for approval/processing
   * **Disconnected:** Field technician extracts PR from device and manually uploads PR in the [Provisioning](/manage-devices/begin-device-provisioning) page
7. **Request processing:** PR appears in Guardian's [Devices](/manage-devices/manage-device-provisioning) page for approval/processing
8. **Profile download:** Download Certified Profile (CP) from [Provisioning](/manage-devices/begin-device-provisioning) page
9. **Install profile & complete provisioning:** Install CP via connected or disconnected method:
   * **Connected:** CP is automatically downloaded from Guardian and automatically installed on the device. Device is automatically marked as **Provisioned** in Guardian.
   * **Disconnected:** CP is manually downloaded from the [Provisioning](/manage-devices/begin-device-provisioning) page and manually installed on the device. Click Complete provisioning to mark it as Provisioned in Guardian.

### **Key file definitions**

* **Provisioning package:** This contains the bootstrap configuration (key templates, infrastructure services information)
* **Guardian library:** Reads the provisioning package configuration and uses it to:
  * Generate unique cryptographic keys on the device
  * Create a Provisioning Request (PR) that includes the device's public key + identity info
  * The PR is like a CSR but more comprehensive (includes additional metadata)
* **Provisioning request (PR):** Similar to a Certificate Signing Request (CSR) but more comprehensive with additional data not found in typical CSRs
* **Certified profile (CP):** Contains more than just certificates, including the Root of Trust (RoT) and other configuration data

### Profile types

Guardian uses three types of profiles:

* **Provisioning package:** Used for initial device provisioning into the Root of Trust (RoT), used only during manufacturing.
* **Device files:** The result of the provisioning process, used to initialize Guardian and perform operations. These files are device-locked and may be used for reprovisioning or key rotation.
* **Mock device files:** Test artifacts that can be provided for initial experimentation. They function like device files but are not device-locked and use pre-generated keys rather than device-generated keys.

### **Provisioning package overview**

Your system's provisioning package (formerly called initial provisioning files) enables any device within your system to establish its cryptographic identity. One provisioning package from Medcrypt can bootstrap multiple devices, components, and system instances within your system. Each device uses the provisioning package to generate its unique identity, then the package should be removed from the device immediately for security.

**Provisiong process steps:**

1. **Identity creation**: Device generates its unique cryptographic keys using the provisioning package
2. **Request submission**: Device creates a Provisioning Request (PR) containing its identity information
3. **Certificate generation**: Guardian Cloud processes the request and creates certificates
4. **Profile installation**: Device receives and installs its Certified Profile (CP)

### **Why does provisioning matter?**

* Establishes trust between devices and systems
* Enables secure communication channels
* Meets FDA requirements for device authentication
* Prevents unauthorized access to device functions

### **When does provisioning occur?**

* **Initial provisioning**: First-time setup during manufacturing using provisioning package
* **Reprovisioning**: Updating keys/certificates during device lifecycle using device's unique files

### **Which provisioning approach is right for you?**

* **Reliable internet connectivity?:** Use connected provisioning.
* **No connectivity or have air-gapped systems?:** Use disconnected provisioning.
* **Gateway or hub architecture?**: Use proxy provisioning.
* **High-security manufacturing:** Use disconnected provisioning.
* **Need fastest automated setup?:** Use connected provisioning.

<details>

<summary><strong>Connected provisioning</strong></summary>

**Best for:** Devices with reliable internet connectivity

**How it works:**

* Device automatically communicates with Guardian Cloud
* Provisioning Request (PR) sent via secure TLS connection
* Certified Profile (CP) automatically downloaded and installed
* No manual intervention required

#### **Advantages:**

* Fully automated process
* Faster provisioning
* Real-time status updates
* Immediate error handling

</details>

<details>

<summary>Disc<strong>onnected provisioning</strong></summary>

**Best for:** Devices with no connectivity or restricted network access

**How it works:**

* Device generates Provisioning Request (PR) locally
* PR manually transferred to connected system (USB, etc.)
* PR uploaded to Guardian Cloud via web interface or proxy device
* Certified Profile (CP) downloaded and manually transferred back to device

#### **Advantages:**

* Works in offline environments
* Suitable for high-security manufacturing
* Compatible with air-gapped systems
* Flexible file transfer methods

</details>

<details>

<summary><strong>Proxy provisioning</strong></summary>

**Best for:** Systems where some devices connect through a gateway

**How it works:**

* Gateway device acts as proxy for other devices
* Non-connected devices create PRs locally
* Gateway device uploads PRs and downloads CPs
* Certificates distributed back to individual devices

</details>

### FAQ

**Can a provisioning request expire?**

Yes, a provisioning request can expire once the key used to sign it expires.


# Begin device provisioning

## Device provisioning overview

Device provisioning requires back-and-forth communication with Guardian Cloud. If the provisioning device has a direct connection to Guardian Cloud, this is referred to as **Connected** provisioning. If the provisioning device does not have a direct connection to Guardian Cloud, this is referred to as **Disconnected** provisioning. **Proxy** provisioning is a special case where a device that can complete Connected provisioning can proxy a Provision Request for a device completing Disconnected provisioning.

## General prerequisites

Before beginning device provisioning, ensure you have:

* Guardian account
* Created and configured your system in Guardian
* Received your provisioning package from Medcrypt
* Downloaded and installed Guardian Library for your platform&#x20;
* Installed provisioning package on your device&#x20;

Check the method you will be using for additional prerequisites.

## Provisioning methods

Choose the provisioning method that best fits your device's connectivity and integration requirements:

* [**Provision using Guardian API**](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#device-provisioning-functions)**:** Use the Guardian Library directly in your application code for full programmatic control over the provisioning process. Ideal for devices that need deep integration with Guardian's cryptographic operations.
* [**Provision via the UI**](#provisioning-via-the-ui)**:** Use the Guardian web interface to manually upload provisioning requests and download certified profiles.&#x20;
  * **Disconnected devices:** Best for devices without network connectivity where field technicians handle file transfers manually.
* [**Provision using command line**](#provision-via-the-command-line)**:** Use the `mcguard_provision` utility for testing, devices that cannot integrate Guardian Library, or proxy provisioning setups:
  * **Connected devices:** Devices with network connectivity that can communicate directly with Guardian Cloud.
  * **Disconnected devices:** Offline provisioning when devices have no network connectivity.
  * **Proxy provisioning:** Use utility with a gateway device that acts as a proxy for other devices without direct internet access.

### What's covered in this topic

* **Disconnected provisioning:** Users can use the command line or the [Provisioning](/manage-devices/begin-device-provisioning) page to submit provision requests (PRs) and download certified profiles (CPs). They can then manage device provisioning and export the device provisioning report from the **Devices** page. This is an interim solution while we add full provisioning lifecycle support to the **Devices** page. For the full workflow walkthrough, refer to [Understand device provisioning](/manage-devices/understand-device-provisioning).
* **Connected provisioning:** Devices automatically submit requests to the [Devices](/manage-devices/manage-device-provisioning) page, and Guardian automatically sends a CP to the respective device.&#x20;
* **Proxy provisioning:** A proxy is provisioned, then used to provision other devices.

## Guardian file types and extensions

Guardian uses several file types with specific extensions during the provisioning process:

**Provision Request:** File used for transmitting information including public keys to the Guardian Cloud backend. This contains the Certificate Signing Requests (CSRs) sent to Guardian Cloud. Extension: `.mcpr`

**TrustStore:** Trust anchors for the Guardian platform. Extension: `.mcts`

**Profile files:**

1. **Certified Profile to be Provisioned:** Signed instructions and configuration for the Guardian library and provisioning operations. This is the initial profile template for this device type created during the provisioning process. Extension: `.mcpp`
2. **Certified Profile:** Signed instructions and configuration for the Guardian library run and reprovisioning operations. This is the final device profile created during the provisioning process. Extension: `.mcp`

**Identity files:**&#x20;

1. **Private Identity to be Provisioned:** Key material for initial provisioning operations and connections. This is the initial private identity template. Extension: `.mcpip`
2. **Private Identity:** Key material for reprovisioning and run operations and connections. This is the final private identity file, which contains the private keys that stay on the device. Extension: `.mcpi`

### File usage by operation type

**Files used during provisioning:**

* TrustStore
* Private Identity for Provisioning
* Certified Profile for Provisioning

**Files used during reprovisioning:**

* TrustStore
* Private Identity
* Certified Profile

Files used when running

* TrustStore
* Private Identity
* Certified Profile

## General provisioning steps

### 1. Generate device keys and provision request (PR)

* This step is done on the provisioning device for maximum key security.
* Can be completed using either the Guardian library API or `mcguard_provision` CLI utility
* A PR contains a bundle of multiple certificate signing requests (CSRs) with all information necessary for Guardian Cloud to issue the resulting provisioned profile and certificates.
  * A CSR contains:
    * **Public key** - the cryptographic key that will be embedded in the issued certificate
    * **Identity information** - details like organization name, device identifier, intended use
    * **Digital signature** - proves the requester possesses the corresponding private key
  * How CSRs work:
    1. Device generates a public/private key pair
    2. Device creates CSR containing the public key + identity info
    3. Device signs the CSR with its private key
    4. CSR is sent to Certificate Authority (Guardian Cloud in your case)
    5. CA validates the request and issues a certificate
    6. Private key never leaves the device
* The keys are stored in the generated Private Identity.

### 2. Submit PR to Guardian Cloud

* **Connected provisioning:**&#x20;
  * API or CLI: Use the Guardian library API or `mcguard_provision` CLI utility to automatically submit the generated PR to Guardian Cloud and retrieve the respective certified profile. completing that device's provisioning.
* **Disconnected provisioning:** Upload the generated PR using the Guardian Cloud UI.

### 3. Retrieve Certified Profile (CP) from Guardian Cloud

* **Connected provisioning:**&#x20;
  * CLI: When the device's PR has been processed, its certified profile will be automatically retrieved.
  * API: Use the Guardian library API to retrieve the certified profile.
* **Disconnected provisioning:** Download the issued certified profile from the Guardian Cloud UI, then install it on the respective device.

## Provision via the UI

### Disconnected provisioning method

Use this method when devices have no network connectivity and field technicians must manually handle file transfers.

**Additional prerequisites:**

* Provisioning request (.mcpr file) extracted from your device

**Steps for disconnected provisioning:**

You can begin the provisioning process from the **Provisioning** page, then [manage provisioning](/manage-devices/manage-device-provisioning) from the Devices page.&#x20;

1. **Extract PR from device:** Field technician extracts the provisioning request ( `.mcpr` file) generated by the device.
2. Select a system name from the quick filter drop-downs on this page. You can only select one system name, also known as your system definition.
3. After signing in to Guardian, click the **Provisioning** item in the sidebar.&#x20;
4. Click the **Begin provisioning** button. This will prompt you to upload a provisioning request. This is an `.mcpr` file.&#x20;
5. **Monitor approval:** PR will appear in [Devices](/manage-devices/manage-device-provisioning) page for approval/processing workflow
   * **Systems with automatic approval:** Guardian will automatically move device PRs through the approval process, then send each device's certified profile (CP) directly to the device.
   * **Systems with manual approval:** Your team will manually approve or reject, then manually complete provisioning.&#x20;
6. **Download profile (disconnected):** When the provisioning request has been processed, you'll be prompted to download the certified profile or CP ( `.mcp` file) from the **Provisioning** page.
7. **Complete provisioning (disconnected):** CP is manually downloaded from the [Provisioning](/manage-devices/begin-device-provisioning) page and manually installed on the device. Click **Complete provisioning** to mark it as **Provisioned** in Guardian.

### Connected provisioning method

Connected devices will automatically send their provisioning requests (PRs) to Guardian Cloud.&#x20;

* Systems with automatic approval, Guardian will automatically move device PRs through the approval process, then send each device's certified profile (CP) directly to the device.
* Systems with manual approval: Your team will manually approve or reject, then manually complete provisioning in the [Devices](/manage-devices/manage-device-provisioning) page.&#x20;

For both approval types, the CP is automatically downloaded from Guardian and automatically installed on the device, then the device is automatically marked as **Provisioned** in Guardian.

## Provision via the command line

Use the `mcguard_provision` utility for testing provisioning workflows, devices that cannot integrate Guardian Library, or proxy provisioning setups.&#x20;

The command line tool supports:

* Connected devices with network connectivity
* Disconnected devices requiring offline provisioning
* Proxy scenarios where a gateway device handles provisioning for other devices

For complete command syntax, examples, and troubleshooting guidance, see [Provision devices using command line](/manage-devices/begin-device-provisioning/provision-devices-using-command-line).

## Provision via the API

You can [provision device using the Guardian API](/manage-devices/begin-device-provisioning/provision-devices-using-api), encompassing device setup, generating secure credentials, and establishing trusted connections. To do so, you'll need to integrate the Guardian Library  into your application code. This provides full programmatic control over the provisioning process through function calls rather than external tools or manual steps.

The API supports connected, disconnected, and proxy provisioning workflows. For complete implementation details, function documentation, and code examples, see [Provision devices using API](/manage-devices/begin-device-provisioning/provision-devices-using-api).

#### When to use the API:

* You need to embed provisioning logic directly in your device software
* You need automated provisioning workflows without manual intervention
* You need fine-grained control over the provisioning process
* You need to integrate with existing device management systems

## Debugging and logging

Guardian does not create log files. Instead, logging is controlled by the application:

* Guardian logs to `stdout` and `stderr`, which appear in the terminal/CLI of the running application during execution. Look for specific error codes or connection failures in the output.
* **Custom logging:** Use `SetLoggingCallback` to redirect log messages to a callback function, stopping terminal output and allowing custom log handling
* **Log control:** Applications can control log level and verbosity.
* **Guardian Cloud UI**: Check the Guardian Cloud interface for additional error details and provisioning status.


# Provision devices using API

## Overview

The Guardian API provides full lifecycle device provisioning, as well as secure communication and cryptographic operations for medical devices. By integrating the [Guardian Library](/overview/what-is-guardian#guardian-components) directly into your application code, you gain programmatic control over the entire provisioning process without the need for manual intervention or external tools.

This topic focuses on the three main provisioning workflows you can accomplish with the API:&#x20;

* [Disconnected devices](#disconnected-device-provisioning)
* [Connected devices](#connected-device-provisioning)
* [Proxy provisioning](#proxy-device-provisioning)&#x20;

Refer to [Terminology](/get-started/terminology) for more information on process, platform, provisioning and other terms.

### When to use the API

* You need to embed provisioning logic directly in your device software
* You need automated provisioning workflows without manual intervention
* You need fine-grained control over the provisioning process
* You need to integrate with existing device management systems

## General prerequisites

Before beginning device provisioning, ensure you have:

* Guardian account
* Created and configured your system in Guardian
* Received your provisioning package from Medcrypt
* Downloaded and installed Guardian Library for your platform&#x20;
* Installed provisioning package on your device&#x20;

## **Disconnected device provisioning**

**When to use:** For devices without network connectivity where provisioning requests must be manually transferred to Guardian Cloud. or more details on file types and extensions, refer to [Guardian file types](/manage-devices/begin-device-provisioning#guardian-file-types-and-extensions).

1. **Prepare provisioning files:** Load the content of the provisioning files into your application's memory. This includes the following files:

   1. TrustStore (`.mcts`)
   2. Private identity for provisioning (`.mcpip`)
   3. Certified profile for provisioning (`.mcpp`)&#x20;

   Your application refers to the software you are developing that integrates the Guardian Library.&#x20;
2. **Create a new Guardian instance:** This action initializes member variables and puts the system in a startup state.
3. **Generate provision request and private identity files:** Call the [GenerateProvisionRequest()](#step-3-generate-provisioning-request)  function. This is the first provisioning step and the only one in the offline process. It generates device keys and creates a provision request (`.mcpr`) file and a private identity (`.mcpi`) file. The `.mcpi` file contains the private keys that stay on the device.
4. Save the generated provision request and private identity files to local storage.
5. **Upload PR:** Manually upload the provision request file to Guardian Cloud.&#x20;
6. **Download certified profile**: Once the PR is processed and approved, download the `.mcp` file from the Guardian Cloud UI.
7. **Install certified profile on device**: Transfer the `.mcp` file to the device where the `.mcpi` file is located to complete provisioning.

## **Connected device provisioning**

**When to use:** For devices with network connectivity that can communicate directly with Guardian Cloud. It is a fully automated process with no manual intervention required. For more details on file types and extensions, refer to [Guardian file types](/manage-devices/begin-device-provisioning#guardian-file-types-and-extensions).

1. Follow steps 1-3 in [Disconnected provisioning](#disconnected-device-provisioning) above to load your provisioning files, start Guardian, and generate the PR and private identity files.
2. **Submit PR to Guardian Cloud:** Call [StartProvisioningOnline()](/api-reference/api-overview#startprovisioningonline) to automatically submit the provisioning request. This initiates the online provisioning state machine and begins communication with Guardian Cloud.
3. **Monitor provisioning progress:**&#x20;
   1. Call the Run function repeatedly within your application's main loop to exectuve background tasks.&#x20;
   2. Use [IsProvisioningRunning()](#isprovisioningrunning) to check if the process is still active.
4. **Retrieve and save certified profile:**&#x20;
   1. When [IsProvisioningRunning()](#isprovisioningrunning) is `false`, the process is finished.&#x20;
   2. Call [GetProvisionedProfile()](#getprovisionedprofile) to retrieve the completed Certified Profile.&#x20;
5. Persist or save this file to your device's storage.

## Proxy device provisioning

**When to use:** Using a connected device (the proxy) to handle provisioning requests for other disconnected devices.&#x20;

**Setup requirements**

* The **proxy device must be provisioned as a fully online component** before it can upload other devices' provisioning requests.
* The disconnected device's `.mcpr` file must be transferred to the proxy device first

**Provision using proxy**

1. **Initialize the proxy device:** The proxy device must first be provisioned as a fully online component. You must initialize the Guardian instance on the proxy device with the proxy's own certified profile (`.mcp`) – this is the final profile file.
2. **Retrieve and save certified profile for other device:**&#x20;
   1. When [IsProvisioningRunning()](#isprovisioningrunning) is `false`, the process is finished.&#x20;
   2. Call [GetProvisionedProfile()](#getprovisionedprofile) to retrieve the completed certified profile.&#x20;
3. **Install certified profile on device**: Transfer the `.mcp` file to the device where the `.mcpi` file is located to complete provisioning.

## Function overview

### Device provisioning functions

* [Guardian](#step-1-run-guardian) : The constructor does no work besides initializing member variables.
* [Initialize](#step-2-run-initialize): Uses the provided profile, identity, and trust files to initialize the Guardian system.
* [GenerateProvisionRequest](#step-3-run-generateprovisionrequest): This is the first device provisioning step for the provisioning process.
* [StartProvisioningOnline](#step-4-startprovisioningonline): Start the online device provisioning process.
* [IsProvisioningRunning](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#function-isprovisioningrunning): Check if provisioning process is active.
* [GetProvisionedProfile](#getprovisionedprofile): Extract provisioned certified profile for device after successful device provisioning.

### Certificate management functions

* [GetCertificateManager:](#getcertificatemanager) Retrieve the running certificate manager.
* [GetProvisionedRevocationList](#getprovisionedrevocationlist): Retrieve certificate revocation list and populate into buffer.&#x20;

### **Security operations functions**

* [FindSecureOperation](#findsecureoperation):  Perform a lookup to get secure operation handler for signing/verification

### **Service management functions**

* [FindService:](#findservice) Perform a service name lookup to locate a configured service.
* [CreateTask](#createtask-service-variant): Create a task for service, session, or channel operations that separates the provided object and all children from [Run](#run).

### **System management functions**

* [GetAuthenticationManager](#getauthenticationmanager): Retrieve the running authentication manager.
* [GetTelemetryManager](#gettelemetrymanager): Retrieve the running telemetry manager.
* [\~Guardian](#guardian): The destructor attempts a graceful shutdown of Guardian.
* [Shutdown](#shutdown): Clean shutdown of Guardian

## File types

Guardian uses several file types with specific extensions during the provisioning process:

**Provision Request:** File used for transmitting information including public keys to the Guardian Cloud backend. This contains the Certificate Signing Requests (CSRs) sent to Guardian Cloud. Extension: `.mcpr`

**TrustStore:** Trust anchors for the Guardian platform. Extension: `.mcts`

**Profile files:**

1. **Certified Profile to be Provisioned:** Signed instructions and configuration for the Guardian library and provisioning operations. This is the initial profile template for this device type created during the provisioning process. Extension: `.mcpp`
2. **Certified Profile:** Signed instructions and configuration for the Guardian library run and reprovisioning operations. This is the final device profile created during the provisioning process. Extension: `.mcp`

**Identity files:**&#x20;

1. **Private Identity to be Provisioned:** Key material for initial provisioning operations and connections. This is the initial private identity template. Extension: `.mcpip`
2. **Private Identity:** Key material for reprovisioning and run operations and connections. This is the final private identity file, which contains the private keys that stay on the device. Extension: `.mcpi`

* **Certificate Revocation List:** Revoked certificates are included in the `.mccrl` file.

## Device setup and provisioning workflow

These steps cover the core provisioning functions for Guardian.

### Step 1: Create Guardian instance

The `Guardian()`  function creates a new Guardian instance and puts it into startup state, ready for initialization. Refer to [Guardian function](/api-reference/api-overview#guardian) for more details.

### Step 2: Initialize Guardian

The `Initialize()` function initializes Guardian with device credentials and configuration files. It uses the provided profile, identity, and trust files to initialize the guardian system. Refer to [Initialize function](/api-reference/api-overview#initialize) for more details.

### Step 3: Generate device provisioning request

The `GenerateProvisionRequest()` function creates a provisioning request for establishing device identity. Refer to [GenerateProvisionRequest function](/api-reference/api-overview#generateprovisionrequest) for more details.

### Step 4: Submit & process provision request

The `StartProvisioningOnline()` function starts the online provisioning process for connected devices to submit a provisioning request to Guardian Cloud.

### Step 5: Monitor provisioning & retrieve device's certified profile

1. Call `Run()` repeatedly to process provisioning tasks
2. Call `IsProvisioningRunning()` to check if provisioning is complete
3. When `IsProvisioningRunning()` returns false, call `GetProvisionedProfile()` to retrieve the certified profile

Refer to [request processing functions](/api-reference/api-overview#run) for more details.

## Debugging and logging

Guardian does not create log files. Instead, logging is controlled by the application:

* Guardian logs to `stdout` and `stderr`, which appear in the terminal/CLI of the running application during execution. Look for specific error codes or connection failures in the output.
* **Custom logging:** Use `SetLoggingCallback` to redirect log messages to a callback function, stopping terminal output and allowing custom log handling
* **Log control:** Applications can control log level and verbosity.
* **Guardian Cloud UI**: Check the Guardian Cloud interface for additional error details and provisioning status.


# Provision devices using command line

## Overview

Use the `mcguard_provision` utility to generate and upload provisioning requests for testing or when devices cannot use Guardian Library. The command line tool supports both connected and disconnected provisioning workflows, as well as proxy provisioning setups.

#### When to use mcguard\_provision:

* Testing provisioning workflows
* Devices that cannot integrate Guardian Library
* Advanced troubleshooting scenarios
* Proxy provisioning setups where a gateway device handles provisioning for other devices

### Additional prerequisites

Make sure that you also have the [general provisioning prereqs](/manage-devices/begin-device-provisioning#general-prerequisites) before beginning provisioning. To use the command line, you'll also need these prereqs:

* `mcguard_provision` utility installed
* Device information readily available (component name, system ID, hardware ID)
* **For proxy provisioning only:** Proxy device must be provisioned as a fully online component first.

## **Technical requirements**

### **Platform compatibility**

* **Linux/BSD hosts:** Commands are formatted for Linux/BSD hosts.&#x20;
* **Windows hosts:**&#x20;
  * Add `.exe` to the executable name
  * Switchpaths from `/` to `\` notation&#x20;

### **File organization**

All command line utilities use a working directory approach. For example, during Connected initial provisioning, the `mcguard_provision` utility expects to see a `.mcts`, `.mcpip` and `.mcpp` file in the working directory.&#x20;

* All source profile files (.mcts, .mcpi, .mcpip, .mcp, .mcpp) should appear in the same folder as the provided profile path.
* Any `mcguard_provision` CLI outputs are saved to the same working directory.&#x20;

### **Network configuration**

* Use default Guardian Cloud endpoints unless Medcrypt specifies a different IP address override for you
* Use default timeout settings unless Medcrypt directs you to modify timeout configurations
* Both of these are controlled in the `provisioningOptions` , but should only be modified as directed by Medcrypt.&#x20;

### **Example parameters**

The following example values are used throughout the command examples in this documentation:

* Provisioning component: `my_component`
* Provisioning host: `35.164.222.194:19109`
* Provisioning system: `my_system`
* Provisioning hardware ID: `my_hid`
* Proxy component: `my_proxy`
* Proxy system: `my_proxy_system`
* Proxy hardware ID: `my_proxy_hid`

Replace these with your actual device and system information.

## Connected device provisioning

Use this method for devices with network connectivity that can communicate directly with Guardian Cloud. Refer to [Guardian file types](/manage-devices/begin-device-provisioning#guardian-file-types-and-extensions) for more details on file types and extensions.

### **Initial provisioning**

1. Run this command to generate the provision request (`.mcpr` file) and private identity (`.mcpi` file) in your working directory, automatically submit them to Guardian Cloud, then automatically retrieve the certified profile (`.mcp` file) to the device. The device will be fully provisioned when the command completes successfully.

```bash
# Syntax
./mcguard_provision --mode provision --component <component_name> --system <system_name> --hardware-id <hardware_id> --ip-address <guardian_host:port> <path_to_initial_provisioning_profile>

# Example
./mcguard_provision --mode provision --component my_component --system my_system --hardware-id my_hid --ip-address 35.164.222.194:19109 /home/user/guardian/profiles/initial_profile
```

### **Reprovisioning**

1. Run this command to generate a new provision request using your existing private identity, automatically submit it to Guardian Cloud, and retrieve the updated certified profile. The device will be reprovisioned when the command completes successfully.

```bash
# Syntax
./mcguard_provision --mode reprovision --component <component_name> --system <system_name> --hardware-id <hardware_id> --ip-address <guardian_host:port> --reprovision <path_to_provisioned_profile>

# Example
./mcguard_provision --mode reprovision --component my_component --system my_system --hardware-id my_hid --ip-address 35.164.222.194:19109 --reprovision /home/user/guardian/profiles/provisioned_profile
```

## Disconnected device provisioning

Use this method for devices without network connectivity where provisioning requests must be manually transferred to Guardian Cloud.

### **Initial provisioning**

1. Run this command to generate the provision request (`.mcpr` file) and private identity (`.mcpi` file) in your working directory.&#x20;

```bash
# Syntax
./mcguard_provision --mode provision --component <component_name> --system <system_name> --hardware-id <hardware_id> --offline <path_to_initial_provisioning_profile>

# Example
./mcguard_provision --mode provision --component my_component --system my_system --hardware-id my_hid --offline /home/user/guardian/profiles/initial_profile
```

2. **Upload provision request:** Manually upload the `.mcpr` file to the Guardian Cloud UI.
3. **Download certified profile**: Once processed, download the `.mcp` file from the Guardian Cloud UI.
4. **Install on device**: Transfer the `.mcp` file to the device where the `.mcpi` file is located to complete provisioning.

### **Reprovisioning**

1. Run this command to generate a new provision request (`.mcpr` file) using your existing private identity (`.mcpi` file).&#x20;

```bash
# Syntax
./mcguard_provision --mode reprovision --component <component_name> --system <system_name> --hardware-id <hardware_id> --offline <path_to_provisioned_profile>

# Example
./mcguard_provision --mode reprovision --component my_component --system my_system --hardware-id my_hid --offline /home/user/guardian/profiles/provisioned_profile
```

2. **Upload provision request:** Manually upload the `.mcpr` file to the Guardian Cloud UI.
3. **Download certified profile**: Once processed, download the `.mcp` file from the Guardian Cloud UI.
4. **Install on device**: Transfer the `.mcp` file to the device where the `.mcpi` file is located to complete reprovisioning.

## Proxy device provisioning

{% hint style="success" %}
**Proxy setup requirements:**

* The **proxy device must be provisioned as a fully online component** before it can upload other devices' provisioning requests.
* The disconnected device's `.mcpr` file must be transferred to the proxy device first
* When uploading using a proxy device, **use the proxy device's component and hardware ID**, NOT the device that created the provisioning request.
  {% endhint %}

1. Run this command to provision the proxy device. The proxy will generate its provision request (`.mcpr`) and private identity (`.mcpi`), automatically submit to Guardian Cloud, and automatically retrieve its certified profile. Once complete, the proxy device can handle provisioning requests for other devices.

```bash
# Syntax
./mcguard_provision --mode provision --component <proxy_component> --system <proxy_system> --hardware-id <proxy_hardware_id> --ip-address <guardian_host:port> <path_to_proxy_provisioning_profile>

# Example
./mcguard_provision --mode provision --component my_proxy --system my_proxy_system --hardware-id my_proxy_hid --ip-address 35.164.222.194:19109 /home/user/guardian/proxy/provisioning_profile
```

**2. Upload the provisioning request via proxy:**&#x20;

1. Run this command to submit a disconnected device's provision request through the proxy device. The proxy will automatically upload the `.mcpr` file to Guardian Cloud and retrieve the certified profile (`.mcp` file).

```bash
# Syntax
./mcguard_provision --mode upload --component <proxy_component> --hardware-id <proxy_hardware_id> --ip-address <guardian_host:port> --provision-request <path_to_disconnected_device_pr> --output-profile <path_to_output_certified_profile> <path_to_provisioned_proxy_profile>

# Example
./mcguard_provision --mode upload --component my_proxy --hardware-id my_proxy_hid --ip-address 35.164.222.194:19109 --provision-request /home/user/device_requests/device_pr.mcpr --output-profile /home/user/certificates/device_cp.mcp /home/user/guardian/proxy/provisioned_profile
```

2\. Transfer to the certified profile to the disconnected device.

### Parameter reference

Each of these parameters precedes the actual value of the object except `--offline`.

**Required parameters:**

* **--mode:** Used during provisioning, reprovisioning, or uploading provisioning request.&#x20;
* **--component:** Component name/identifier
* **--system:** System name identifier. This is also known as the system definition.
* **--hardware-id:** Unique hardware identifier (typically a device serial number).

**Connected only:**

* **--ip-address:** Guardian Cloud endpoint (host:port)

**Disconnected only:**

* **--offline:** Enable offline/disconnected mode

**Reprovisioning only:**

* **--reprovision:** Specify path to existing provisioned profile (`.mcp` file)

**Proxy only:**

* **--provision-request:** Specify path to provision request (`.mcpr` file) for proxy upload

#### Proxy file naming recommendation

When handling files during proxy provisioning, you can name them however you prefer. We recommend:

* Preserving file extensions (`.mcpr` for provision requests, `.mcp` for certified profiles) for easy identification by your team and Medcrypt
* Using descriptive names that identify the device or component
* Including version numbers or dates if managing multiple provisioning attempts

### Troubleshooting for command line

#### **Network connectivity issues**

**Error:** Cannot connect to provisioning endpoints

1. Review Guardian log output or increase log level to identify warnings or errors.
2. Test network connectivity to provisioning endpoints using tools like `telnet` or `netcat`.

```bash
# Syntax
telnet <guardian_host> <port>

# Example
telnet 35.164.222.194 19109
```

3. Check firewall configuration and ensure the Guardian Cloud endpoint is accessible
4. Verify the IP address and port are correct
5. Sign in to Guardian Cloud to review device provisioning reports.
6. Check whether your system definition is configured for automatic or manual approval.

**Prevention**

* Ensure stable network connectivity and proper firewall configuration
* Configure proper firewall rules for Guardian Cloud endpoints
* Test connectivity in your network environment before deployment

```cpp
Status Shutdown(
    const bool & in_force =false
)
```

#### **Command execution issues**

**File not found errors:**

* Verify all required profile files (.mcts, .mcpip, .mcpp) are in the specified directory
* Check file permissions and ensure the utility can read the profile files
* Confirm the profile path is correct and accessible

**Invalid parameter errors:**

* Verify component name, system name, and hardware ID match your Guardian Cloud configuration
* Check that hardware ID follows character limitations (typically 36 characters max)
* Ensure IP address format is correct (host:port)

### **Proxy provisioning issues**

Make sure that you have met the [proxy setup requirements](#proxy-device-provisioning).

**Proxy device not accepted:**

* Confirm the proxy device is fully provisioned and operational. This must be done before the proxy device can be used to provision other devices.
* Verify you're using the proxy device's component and hardware ID, not the target device's.
* Check that the proxy device's profile allows proxy operations.

**File transfer issues:**

* Ensure the provision request (`.mcpr` file) from the disconnected device is accessible to the proxy device.
* Verify file integrity during manual transfer processes.
* Check file permissions allow the proxy device to read the provision request.

## Debugging and logging

Guardian does not create log files. Instead, logging is controlled by the application:

* Guardian logs to `stdout` and `stderr`, which appear in the terminal/CLI of the running application during execution. Look for specific error codes or connection failures in the output.
* **Custom logging:** Use `SetLoggingCallback` to redirect log messages to a callback function, stopping terminal output and allowing custom log handling
* **Log control:** Applications can control log level and verbosity.
* **Guardian Cloud UI**: Check the Guardian Cloud interface for additional error details and provisioning status.


# Device provisioning code examples

## Disconnected provisioning examples

Guardian supports C#, C++, and C for disconnected provisioning.

### C# example

```csharp
public static void DisconnectedProvisioning()
{
    medcrypt.guardian.ProvisionFilesInput provisioningFilesInput =
        new medcrypt.guardian.ProvisionFilesInput();

    /* Customer data about the provisioning system */
    string componentHandle = "my_component_handle";
    string systemId = "my_system_name";
    string hardwareId = "my_serial_number";

    /* Load provisioning files to input file storage buffers */
    provisioningFilesInput.trustStore =
        File.ReadAllBytes(@"TrustStore.mcts");
    provisioningFilesInput.privateIdentity =
        File.ReadAllBytes(@"PrivateIdentity.mcpip");
    provisioningFilesInput.certifiedProfile =
        File.ReadAllBytes(@"CertifiedProvisioningProfile.mcpp");

    /* Create Guardian */
    medcrypt.guardian.Guardian gdn = new medcrypt.guardian.Guardian();

    /* Create default options */
    medcrypt.guardian.ProvisioningGenerateOptions options =
            new medcrypt.guardian.ProvisioningGenerateOptions();

    /* Call generate provision request */
    medcrypt.guardian.ProvisionFilesOutput provisioningOutputFiles =
        gdn.GenerateProvisionRequest(
            provisioningFilesInput,
            options,
            componentHandle,
            systemId,
            hardwareId);

    /* Persist provision request and generated private identity */
    File.WriteAllBytes(
        @"GeneratedPrivateIdentity.mcpi",
        provisioningOutputFiles.generatedPrivateIdentity);
    File.WriteAllBytes(
        @"ProvisionRequest.mcpr",
        provisioningOutputFiles.provisionRequest);
}
```

### C++ example

```cpp
#include "medcrypt/guardian/GuardianSystem.h"
#include "medcrypt/guardian/Utilities/Files/FileHelpers.h"

#define MSG(x) { printf x; printf("\n"); }
#define MSG_INFO(x) { MSG(x); }
#define MSG_ERROR(x) { printf("ERROR: "); MSG(x); }
#define MSG_WARNING(x) { printf("WARNING: "); MSG(x); }
#define ARBITRARY_BUF_SIZE 2 * 1024

static const char kPrFilename[] = "ProvisionRequest.mcpr";
static const char kPiFilename[] = "PrivateIdentity.mcpi";

static bool WriteBufferToFile(
    const std::string& in_filepath,
    const char* in_file_contents,
    const size_t in_file_size);

bool DisconnectedProvisioning()
{
    medcrypt::guardian::utilities::ProvisionFiles files;
    std::string in_component_handle = "my_component_handle";
    std::string in_hardware_id = "my_serial_number";
    std::string in_provisioning_profile_folder =
        "/home/user/guardian/profiles/initial_profile";

    /* Retrieve provisioning files, for an initial provision these are the actual provisioning profile files */
    if (!medcrypt::guardian::utilities::GetProvisionFilesFromPath(
            in_provisioning_profile_folder,
            true,
            &files)) {
        MSG_ERROR(("could not retrieve provisioning files"));
        return false;
    }

    /* Assign buffers to outputs */
    char pr_buf[ARBITRARY_BUF_SIZE] = {0};
    char gpi_buf[ARBITRARY_BUF_SIZE] = {0};

    files.ProvisionRequest = pr_buf;
    files.ProvisionRequestSize = sizeof(pr_buf);
    files.GeneratedPrivateIdentity = gpi_buf;
    files.GeneratedPrivateIdentitySize = sizeof(gpi_buf);

    /* Create Guardian */
    medcrypt::guardian::Guardian guardian;
    medcrypt::guardian::Status status;

    /* Accept input options, or create default, alias hardware id to system name, actually generate the provision request */
    status = guardian.GenerateProvisionRequest(
        files,
        medcrypt::guardian::ProvisioningGenerateOptions(),
        in_component_handle.c_str(),
        in_hardware_id.c_str(),
        in_hardware_id.c_str());

    /* Check and print non-OK error code */
    if (EXTRACT_STATUS(status) != medcrypt::guardian::GuardianStatusEnum::OK) {
        MSG_ERROR(("could not generate provision request [%s]",
            medcrypt::guardian::GuardianStatusEnum::NameOf(
                EXTRACT_STATUS(status)).c_str()));
        return false;
    }

    /* Write the provision request to disk */
    if (!WriteBufferToFile(
            in_provisioning_profile_folder + kPrFilename,
            files.ProvisionRequest,
            files.ProvisionRequestSize))
    {
        MSG_ERROR(("could not write generated provision request"));
        return false;
    }

    /* Write the private identity to disk */
    if (!WriteBufferToFile(
            in_provisioning_profile_folder + kPiFilename,
            files.GeneratedPrivateIdentity,
            files.GeneratedPrivateIdentitySize))
    {
        MSG_ERROR(("could not write generated private identity"));
        return false;
    }

    return true;
}

static bool
WriteBufferToFile(
    const std::string& in_filepath,
    const char* in_file_contents,
    const size_t in_file_size)
{
    bool return_value = false;

    std::ofstream output(in_filepath, std::ios::binary);
    if( output.good() &&
        in_file_size <= (std::numeric_limits<std::streamsize>::max)())
    {
        output.write(in_file_contents, static_cast<std::streamsize>(in_file_size));
        output.close();
        return_value = true;
    }

    return return_value;
}
```

### C example

The C interface uses streams for all large inputs and outputs. The example below will show these streams backed by buffers. Output buffers will be arbitrarily sized.

```c
#define MAX_GDN_SIZE 15 * 1024 /* Increase as necessary, this memory does not have to be on the stack */
#define ARBITRARY_BUF_SIZE 5 * 1024 /* Increase as necessary */

static bool disconnected_provisioning()
{
    mcg_status status = 0;
    /* Create Guardian memory region, this memory can come from any source but must be a continuous block */
    mcg_memory_t mcg_memory = {NULL, 0, 0};
    uint8_t memory_buffer[MAX_GDN_SIZE] = {0};

    /* Initialize file pointer storage structs along with input and output streams */
    mcg_provision_files_t prov_files = {0};
    mcg_provisioning_generate_options_t p_options = {0};
    mcg_guardian_istream_t ts, pi, cp;
    mcg_guardian_ostream_t pr = {0};
    mcg_guardian_ostream_t gpi = {0};

    /* Customer data about this provisioning system */
    char component_handle[] = "my_component";
    char system_name[] = "my_system_name";
    char hardware_id[] = "my_serial_number";

    mcg_memory.mem = &memory_buffer[0];
    mcg_memory.size = sizeof(memory_buffer);

    /* Read trust store into this buffer, and set in_ts_len to actual size */
    uint8_t in_ts[ARBITRARY_BUF_SIZE] = {0};
    size_t in_ts_len = 1234;

    /* Read private identity into this buffer, and set in_pi_len to actual size */
    uint8_t in_pi[ARBITRARY_BUF_SIZE] = {0};
    size_t in_pi_len = 1234;

    /* Read certified profile into this buffer, and set in_cp_len to actual size */
    uint8_t in_cp_prov[ARBITRARY_BUF_SIZE] = {0};
    size_t in_cp_prov_len = 1234;

    /* Allocate memory for provision request and generated private identity output */
    uint8_t io_pr[ARBITRARY_BUF_SIZE] = {0};
    size_t io_pr_len = sizeof(pr);
    uint8_t io_gpi[ARBITRARY_BUF_SIZE] = {0};
    size_t io_gpi_len = sizeof(gpi);

    /* Create streams from provided ts/pi/cp byte buffers */
    ts = mcg_istream_from_buffer(in_ts, in_ts_len);
    pi = mcg_istream_from_buffer(in_pi, in_pi_len);
    cp = mcg_istream_from_buffer(in_cp_prov, in_cp_prov_len);

    /* Create output streams for provision request and generated private
        identity */
    pr = mcg_ostream_from_buffer(io_pr, io_pr_len);
    gpi = mcg_ostream_from_buffer(io_gpi, io_gpi_len);

    /* Load streams into mcg_provision_files_t */
    prov_files.trust_store = &ts;
    prov_files.private_identity = &pi;
    prov_files.certified_profile = &cp;
    prov_files.provision_request = &pr;
    prov_files.generated_private_identity = &gpi;

    status = mcg_gdn_generate_provision_request(&mcg_memory,
            &prov_files,
            &p_options,
            component_handle,
            system_name,
            hardware_id);

    if (status != MCG_STATUS_OK) {
        return false;
    }

    io_pr_len = pr.bytes_written;
    io_gpi_len = gpi.bytes_written;

    /* Persist PR (io_pr/io_pr_len) and GPI (io_gpi/io_gpi_len) to storage */

    return true;
}
```

## Connected device provisioning examples

Guardian supports C# and C++ for connected provisioning.

### **C# example**

```csharp
public static void ConnectedProvisioning()
{
    public static void ConnectedProvisioning()
{
    medcrypt.guardian.ProvisionFilesInput provisioningFilesInput =
            new medcrypt.guardian.ProvisionFilesInput();
        medcrypt.guardian.ProvisionFilesOutput provisioningOutputFiles =
            new medcrypt.guardian.ProvisionFilesOutput();
    // Complete Disconnected Provisioning as in DisconnectedProvisioning()
    // The data in provisioningFilesInput and provisioningOutputFiles should
    // come from the DisconnectedProvisioning() function.
    //
    // The static text is reproduced in this function for readability.
    string componentHandle = "my_component_handle";
    string hardwareId = "my_serial_number";

    /* copy provisioning profile files to initialization file storage */
    medcrypt.guardian.InitializeFiles initializeFiles =
        new medcrypt.guardian.InitializeFiles();
    initializeFiles.trustStore = provisioningFilesInput.trustStore;
    initializeFiles.privateIdentity = provisioningFilesInput.privateIdentity;
    initializeFiles.certifiedProfile = provisioningFilesInput.certifiedProfile;

    /* initialize guardian for configured operations (connecting to backend)*/
    medcrypt.guardian.Guardian gdn = new medcrypt.guardian.Guardian();

    gdn.Initialize(
        initializeFiles,
        componentHandle,
        hardwareId,
        new medcrypt.guardian.InitializeOptions());

    /* create default options */
    medcrypt.guardian.ProvisioningOnlineOptions options =
            new medcrypt.guardian.ProvisioningOnlineOptions();

    /* load provision request into online files structure */
    medcrypt.guardian.ProvisioningFilesOnline onlineFiles =
        new medcrypt.guardian.ProvisioningFilesOnline();
    onlineFiles.provisionRequest =
        provisioningOutputFiles.provisionRequest;

    /* start connected provisioning state machine */
    gdn.StartProvisioningOnline(onlineFiles, options);
    gdn.Run();

    /* wait for provisioning to complete, error, or timeout to occur */
    DateTime start = DateTime.Now;
    TimeSpan timeout = TimeSpan.FromMinutes(2);
    while (gdn.IsProvisioningRunning() &&
            System.DateTime.Now - start < timeout)
    {
        gdn.Run();
        System.Threading.Thread.Sleep(500);
    }

    /* persist provisioned profile */
    File.WriteAllBytes(
        @"CertifiedProfile.mcp",
        gdn.GetProvisionedProfile());
}
}
```

### **C++ example**

```cpp
#define ARBITRARY_BUF_SIZE 10 * 1024

static const char kCpFilename[] = "CertifiedProfile.mcp";
bool ConnectedProvisioning()
{

    The static text is reproduced in this function for readability. */
    // Complete Disconnected Provisioning as in DisconnectedProvisioning()
    // The data in DisconnectedProvisioning()'s "files" object should be copied 
    // to "in_files" in this function.
    //
    // The static text is reproduced in this function for readability.
    medcrypt::guardian::utilities::ProvisionFiles in_files;
    std::string in_component_handle = "my_component_handle";
    std::string in_hardware_id = "my_serial_number";
    std::string in_provisioning_profile_folder = "/home/user/guardian/profiles/initial_profile";

     /* Create Guardian */
    medcrypt::guardian::Guardian guardian;
    medcrypt::guardian::Status status;

    /* Initialize Guardian with the provided provisioning profile to enable connecting to medcrypt backend infrastructure */
    medcrypt::guardian::utilities::InitializeFiles init_files;
    init_files.TrustStore           = in_files.TrustStore;
    init_files.TrustStoreSize       = in_files.TrustStoreSize;
    init_files.PrivateIdentity      = in_files.PrivateIdentity;
    init_files.PrivateIdentitySize  = in_files.PrivateIdentitySize;
    init_files.CertifiedProfile     = in_files.CertifiedProfile;
    init_files.CertifiedProfileSize = in_files.CertifiedProfileSize;

    /* Initialize provided Guardian */
    status = guardian.Initialize(
        init_files,
        in_component_handle.c_str(),
        in_hardware_id.c_str(),
        medcrypt::guardian::InitializeOptions());

    /* Check and print non-OK error code */
    if (EXTRACT_STATUS(status) != medcrypt::guardian::GuardianStatusEnum::OK) {
        MSG_ERROR(("could not initialize guardian [%s]",
            medcrypt::guardian::GuardianStatusEnum::NameOf(
                EXTRACT_STATUS(status)).c_str()));
        return false;
    }

    /* Start the internal online provisioning state machine by providing it with the generated provision request */
    medcrypt::guardian::utilities::ProvisionOnlineFiles online_files;
    online_files.ProvisionRequest       = in_files.ProvisionRequest;
    online_files.ProvisionRequestSize   = in_files.ProvisionRequestSize;

    status = guardian.StartProvisioningOnline(
        online_files,
        medcrypt::guardian::ProvisioningOptions());  
    /* Check and print non-OK error code */
    if (EXTRACT_STATUS(status) != medcrypt::guardian::GuardianStatusEnum::OK) {
        MSG_ERROR(("could not start online provisioning [%s]",
            medcrypt::guardian::GuardianStatusEnum::NameOf(
                EXTRACT_STATUS(status)).c_str()));
        return false;
    }

    /* Engage internal state machine */
    status = guardian.Run();
    /* Check and print non-OK error code */
    if (EXTRACT_STATUS(status) != medcrypt::guardian::GuardianStatusEnum::OK) {
        MSG_ERROR(("could not run guardian [%s]",
            medcrypt::guardian::GuardianStatusEnum::NameOf(
                EXTRACT_STATUS(status)).c_str()));
        return false;
    }

    /* Wait for provisioning to complete, error, or timeout to occur */
    auto start = std::chrono::steady_clock::now();
    auto timeout = std::chrono::minutes(2);
    while (guardian.IsProvisioningRunning() &&
                ((std::chrono::steady_clock::now() - start) < timeout)) {
            guardian.Run();
            std::this_thread::sleep_for(std::chrono::milliseconds(500));
    }

    /* Retrieve the received provisioned profile */
    char profile[ARBITRARY_BUF_SIZE] = {0};
    size_t profile_size = sizeof(profile);
    status = guardian.GetProvisionedProfile(
            profile,
            &profile_size);
    /* Check and print non-OK error code */
    if (EXTRACT_STATUS(status) != medcrypt::guardian::GuardianStatusEnum::OK) {
        MSG_ERROR(("could not complete online provisioning [%s]",
            medcrypt::guardian::GuardianStatusEnum::NameOf(
                EXTRACT_STATUS(status)).c_str()));
        return false;
    }

    /* Write the provisioned profile to disk */
    if (!WriteBufferToFile(
            in_provisioning_profile_folder + kCpFilename,
            profile,
            profile_size))
    {
        MSG_ERROR(("could not write provisioned profile"));
        return false;
    }

    return true;
}
```

## Proxy device provisioning examples

Guardian supports C# and C++ for proxy provisioning. Since Guardian does not support connected provisioning, it cannot proxy a provision request.

### **C# example**

```csharp
public static void ConnectedProvisioning()
{
    public static void ConnectedProvisioning()
{
    medcrypt.guardian.ProvisionFilesInput provisioningFilesInput =
            new medcrypt.guardian.ProvisionFilesInput();
        medcrypt.guardian.ProvisionFilesOutput provisioningOutputFiles =
            new medcrypt.guardian.ProvisionFilesOutput();
    // Complete Disconnected Provisioning as in DisconnectedProvisioning()
    // The data in provisioningFilesInput and provisioningOutputFiles should
    // come from the DisconnectedProvisioning() function.
    //
    // The static text is reproduced in this function for readability.
    string componentHandle = "my_component_handle";
    string hardwareId = "my_serial_number";

    /* Copy provisioning profile files to initialization file storage */
    medcrypt.guardian.InitializeFiles initializeFiles =
        new medcrypt.guardian.InitializeFiles();
    initializeFiles.trustStore = provisioningFilesInput.trustStore;
    initializeFiles.privateIdentity = provisioningFilesInput.privateIdentity;
    initializeFiles.certifiedProfile = provisioningFilesInput.certifiedProfile;

    /* Initialize Guardian for configured operations (connecting to backend)*/
    medcrypt.guardian.Guardian gdn = new medcrypt.guardian.Guardian();

    gdn.Initialize(
        initializeFiles,
        componentHandle,
        hardwareId,
        new medcrypt.guardian.InitializeOptions());

    /* Create default options */
    medcrypt.guardian.ProvisioningOnlineOptions options =
            new medcrypt.guardian.ProvisioningOnlineOptions();

    /* Load provision request into online files structure */
    medcrypt.guardian.ProvisioningFilesOnline onlineFiles =
        new medcrypt.guardian.ProvisioningFilesOnline();
    onlineFiles.provisionRequest =
        File.ReadAllBytes(@"ProxiedProvisionRequest.mcpr");

    /* Start connected provisioning state machine */
    gdn.StartProvisioningOnline(onlineFiles, options);
    gdn.Run();

    /* Wait for provisioning to complete, error, or timeout to occur */
    DateTime start = DateTime.Now;
    TimeSpan timeout = TimeSpan.FromMinutes(2);
    while (gdn.IsProvisioningRunning() &&
            System.DateTime.Now - start < timeout)
    {
        gdn.Run();
        System.Threading.Thread.Sleep(500);
    }

    /* Persist provisioned profile */
    File.WriteAllBytes(
        @"CertifiedProfile.mcp",
        gdn.GetProvisionedProfile());
}
}
```

### **C++ example**

```cpp
#define ARBITRARY_BUF_SIZE 10 * 1024

static const char kCpFilename[] = "CertifiedProfile.mcp";
bool ConnectedProvisioning()
{
    /* Complete Disconnected Provisioning as in DisconnectedProvisioning(). The data in from DisconnectedProvisioning()'s "files" object should be copied to "in_files" in this function.
    The static text is reproduced in this function for readability. */
    medcrypt::guardian::utilities::ProvisionFiles in_files;
    std::string in_component_handle = "my_component_handle";
    std::string in_hardware_id = "my_serial_number";
    std::string in_provisioning_profile_folder = "/home/user/guardian/profiles/initial_profile";

     /* Create Guardian */
    medcrypt::guardian::Guardian guardian;
    medcrypt::guardian::Status status;

    /* Initialize Guardian with the provided provisioning profile to enable connecting to medcrypt backend infrastructure */
    medcrypt::guardian::utilities::InitializeFiles init_files;
    init_files.TrustStore           = in_files.TrustStore;
    init_files.TrustStoreSize       = in_files.TrustStoreSize;
    init_files.PrivateIdentity      = in_files.PrivateIdentity;
    init_files.PrivateIdentitySize  = in_files.PrivateIdentitySize;
    init_files.CertifiedProfile     = in_files.CertifiedProfile;
    init_files.CertifiedProfileSize = in_files.CertifiedProfileSize;

    /* Initialize provided Guardian */
    status = guardian.Initialize(
        init_files,
        in_component_handle.c_str(),
        in_hardware_id.c_str(),
        medcrypt::guardian::InitializeOptions());

    /* Check and print non-OK error code */
    if (EXTRACT_STATUS(status) != medcrypt::guardian::GuardianStatusEnum::OK) {
        MSG_ERROR(("could not initialize guardian [%s]",
            medcrypt::guardian::GuardianStatusEnum::NameOf(
                EXTRACT_STATUS(status)).c_str()));
        return false;
    }

    /* Start the internal online provisioning state machine by providing it with the generated provision request */
    medcrypt::guardian::utilities::ProvisionOnlineFiles online_files;
    online_files.ProvisionRequest       = in_files.ProvisionRequest;
    online_files.ProvisionRequestSize   = in_files.ProvisionRequestSize;

    /* Load proxy Provision Request to a buffer and size here */
    char pr_buf[2048] = {0};
    size_t pr_buf_size = sizeof(buf);

    /* Start the internal online provisioning state machine by
    providing it with the generated disconnected provision request */
    medcrypt::guardian::utilities::ProvisionOnlineFiles online_files;
    online_files.ProvisionRequest       = pr_buf;
    online_files.ProvisionRequestSize   = pr_buf_size;

    status = guardian.StartProvisioningOnline(
        online_files,
        medcrypt::guardian::ProvisioningOptions());  
    /* Check and print non-OK error code */
    if (EXTRACT_STATUS(status) != medcrypt::guardian::GuardianStatusEnum::OK) {
        MSG_ERROR(("could not start online provisioning [%s]",
            medcrypt::guardian::GuardianStatusEnum::NameOf(
                EXTRACT_STATUS(status)).c_str()));
        return false;
    }

    /* Engage internal state machine */
    status = guardian.Run();
    /* Check and print non_OK error code */
    if (EXTRACT_STATUS(status) != medcrypt::guardian::GuardianStatusEnum::OK) {
        MSG_ERROR(("could not run guardian [%s]",
            medcrypt::guardian::GuardianStatusEnum::NameOf(
                EXTRACT_STATUS(status)).c_str()));
        return false;
    }

    /* Wait for provisioning to complete, error, or timeout to occur */
    auto start = std::chrono::steady_clock::now();
    auto timeout = std::chrono::minutes(2);
    while (guardian.IsProvisioningRunning() &&
                ((std::chrono::steady_clock::now() - start) < timeout)) {
            guardian.Run();
            std::this_thread::sleep_for(std::chrono::milliseconds(500));
    }

    /* Retrieve the received provisioned profile*/
    char profile[ARBITRARY_BUF_SIZE] = {0};
    size_t profile_size = sizeof(profile);
    status = guardian.GetProvisionedProfile(
            profile,
            &profile_size);
    /* Check and print non-OK error code */
    if (EXTRACT_STATUS(status) != medcrypt::guardian::GuardianStatusEnum::OK) {
        MSG_ERROR(("could not complete online provisioning [%s]",
            medcrypt::guardian::GuardianStatusEnum::NameOf(
                EXTRACT_STATUS(status)).c_str()));
        return false;
    }

    /* Write the provisioned profile to disk */
    if (!WriteBufferToFile(
            in_provisioning_profile_folder + kCpFilename,
            profile,
            profile_size))
    {
        MSG_ERROR(("could not write provisioned profile"));
        return false;
    }

    return true;
}
```


# Manage device provisioning

You can manage device provisioning in the **Devices** page of Guardian, as well as export your device provisioning report. You can begin the provisioning process from the [Provisioning](/manage-devices/begin-device-provisioning) page.

**Disconnected provisioning**

For disconnected provisioning, users can use the command line or the [Provisioning](/manage-devices/begin-device-provisioning) page to submit PRs and download certified profiles (CPs). They can then manage device provisioning and export the device provisioning report from the **Devices** page. This is an interim solution while we add full provisioning lifecycle support to the **Devices** page. For the full workflow walkthrough, refer to [Understand device provisioning](/manage-devices/understand-device-provisioning).

**Connected provisioning**

For connected provisioning, devices automatically submit requests to the [Devices](/manage-devices/manage-device-provisioning) page.&#x20;

## Select system

1. In the breadcrumb trail in the main navigation bar, click the **Select system name** drop-down. You can also select this in the quick filter drop-downs on the page. You can only select one system name, also known as your system definition.
2. Click the **Filters** drop-down to filter on system instance, component, and other criteria.

## Understanding approval workflows

### Automatic approval type

In this approval workflow type, provisioning requests (PRs) will automatically be verified, approved, and provisioned. You cannot manually approve or reject PRs for this approval type. This approval workflow has the following steps:

**Verifying** → **Auto-approved** → **Provisioning** → **Provisioned**

* **Verifying...**: PR has just come in and the system has not yet auto-approved it.
* **Auto-approved:** PR has been auto-approved by the system and will soon move to **Provisioning**.
* **Provisioning:** PR is either in the process of provisioning or is queued to provision soon.
* **Provisioned:** PR has completed provisioning
* **Various error codes:** See [Troubleshooting](#troubleshooting) for more informatio&#x6E;**.**&#x20;

### Manual approval type

Provisioning requests require manual approval before processing.

This approval workflow has the following steps:

**Verifying** → **Needs approval** → **Approving** → **Complete provisioning** → **Provisioning** → **Provisioned**

* **Verifying...:** PR has just come in and the system has not yet moved it to **Needs approval** status.
* **Needs approval:** PR needs to be manually approved by a user.
* **Approving...:** PR approval is in progress
* **Complete provisioning:** PR needs to be manually provisioned by a user
* **Provisioning:** PR is either in the process of provisioning or is queued to provision soon.
* **Provisioned:** PR has completed provisioning
* **Rejecting...**: PR rejection is in progress
* **Rejected by user:** PR was manually rejected by a user.
* **Various error codes:** See [Troubleshooting](#troubleshooting) for more informatio&#x6E;**.**&#x20;

### Approve individual PR

For the **Manual** approval type, you can approve PRs for one or more devices. Approved PRs will move to **Approved** status.

1. For any PR in the **Needs approval** status, you will see an **Approve** and **Reject** button in the **Actions** column.&#x20;
2. Click **Approve.** This will display the confirmation panel.&#x20;
3. Click **Approve PR** in the panel. The PR status will move to **Approving...**, then to **Complete provisioning.** You will see a success message.
4. If you choose to reject the PR at this point, click **Reject PR**. This will change its status to **Rejected by user**. You will see a success message.
5. You can view **Approved on** and **Approved by** information. Click the **Columns** link at the top of the table to customize your display.

### Bulk approve PRs

For the **Manual** approval type, you can approve or reject PRs for one or more devices. Approved PRs will move to **Approved** status.

1. For any PR in the **Needs approval** status, you will see an **Approve** and **Reject** button in the **Actions** column. You will also see the total number of PRs in this status in the bulk **Approve X PRs** action link in the toolbar (where X is this number).
2. Click **Approve X PRs** in the toolbar. This will display the confirmation panel.&#x20;
3. Click **Approve X PRs** in the panel. The PR status will move to **Approving...**, then to **Complete provisioning.** You will see a success message.&#x20;
4. If you choose to reject the PR at this point, click **Reject X PRs**. This will change their status to **Rejected by user**. You will see a success message.

### Reject individual PR

For the **Manual** approval type, you can reject PRs for one or more devices. Rejected PRs will show a **Rejected by user** status.

1. For any PR in the **Needs approval** status, you will see an **Approve** and **Reject** button in the **Actions** column.&#x20;
2. Click **Reject.** This will display the confirmation panel.&#x20;
3. Click **Reject PR** in the panel. The **Provisioning status** will move to the **Rejected by user** status. You will see a success message.
4. You can view **Rejected on** and **Rejected by** information. Click the **Columns** link at the top of the table to customize your display.

### Bulk reject PRs

For the **Manual** approval type, you can bulk reject PRs for one or more devices. Rejected PRs will move to **Rejected** **by user** status.

1. For any PR in the **Needs approval** status, you will see an **Approve** and **Reject** button in the **Actions** column. You will also see the total number of PRs in this status in the bulk **Reject X PRs** action link in the toolbar (where X is this number).
2. Click **Reject X PRs** in the toolbar. You'll have the opportunity to review the summary of the PRs you are rejecting.
3. Confirm your rejection. The **Provisioning status** will move to **Rejecting...**, then **Rejected by user** status. You will see a success message.
4. You can view **Rejected on** and **Rejected by** information. Click the **Columns** link at the top of the table to customize your display.

### Provision individual device

For the **Manual** approval type, after approving device PRs, you can provision those devices individually or in bulk.&#x20;

1. For any PR in the **Complete provisioning** status, you will see a **Provision** button in the **Actions** column.&#x20;
2. Click **Provision**. This will display the confirmation panel.
3. Click **Provision device** in the panel. The **Provisioning status** will move to **Provisioning...**, then Provisioned status. You will see a success message.
4. You can view **Rejected on** and **Rejected by** information. Click the **Columns** link at the top of the table to customize your display. You will see a success message.

### Bulk provision devices

For the **Manual** approval type, after approving device PRs, you can provision those devices individually or in bulk.

1. For any PR in the **Complete provisioning** status, you will see that device reflected in the **Provision X devices** action link in the toolbar. You will also see a **Provision** button in the **Actions** column.&#x20;
2. Click **Provision**. This will display the confirmation panel.
3. Click **Provision X devices** in the panel. The **Provisioning status** will move to **Provisioning...**, then **Provisioned** status. You will see a success message.
4. You can view **Rejected on** and **Rejected by** information. Click the **Columns** link at the top of the table to customize your display. You will see a success message.

## Change date formatting

By default, device provisioning data is displayed in UTC time and in **dd mmm yyyy** format. You can change this to display ISO format and/or to show dates in your local time.

1. To change the date formatting, click the **Settings** drop-down in the toolba&#x72;**.**
2. Toggle the respective date settings, which will automatically apply.

## Columns

Not all columns are shown by default. Click the **Columns** link at the top of the table to customize your display.

* **System name:** This is the system definition. It will also be referred to as system.
* **System instance name:** This is a particular instance of the system name.
* **System instance ID:** This is the unique ID for a system instance.
* **Component name:** This is a component in the system instance.
* **Component instance ID:** This is the unique ID for a component.
* **Component instance created on:** This is when the component instance was created.
* **Device HW ID:** This is the unique ID for a device.&#x20;
* **Approval type:** This is either **Manual** or **Automatic**, as defined by your organization in your system definition.
* **Provisioning status:** This shows the provisioning status of the PR. Statuses will depend on your system's defined approval type.
* **Request ID:** This is the unique provisioning request ID.
* **Request created on:** This is the date the provisioning request was created.
* **Response ID:** This is the unique provisioning response ID.
* **Response created on:** This is the date the provisioning response was created.
* **Provision source:** This is either **Appliance** or **Cloud**, as defined by your organization in your system definition.
* **Approved on:** This is the date the provisioning request was approved.&#x20;
* **Approved by:** This is either **System** or a user name. If you are using the **Automatic** approval type, it will be set to **System**. The PR will also&#x20;
* **Rejected on:** This is the date the provisioning request was rejected.
* **Rejected by:** This is either **System** or a user name. If you are using the **Automatic** approval type, it will be set to **System** if the PR was rejected by our system. It will also have a **Rejected by system** provisioning status.
* **Provisioned on:** This is the date the provisioning request was provisioned.
* **Provisioned by:** This is either **System** or a user name. If you are using the **Automatic** approval type, it will be set to **System** when the PR is automatically provisioned by our system. It will also have a **Provisioned** provisioning status.
* **Actions:** If a PR needs to be approved, this will show **Approve** and **Reject** buttons. If there are additional actions that can be performed, you will see a **... action overflow** button.

## Troubleshooting

If a PR encounters an error during the provisioning process, its **Provisioning status** will indicate the problem.&#x20;

* **Rejected by user:** PR was manually rejected by a user. This will only display for the **Manual** approval type.&#x20;
* **Rejected by system:** PR was automatically rejected by our system. This should be very rare.
* **Must be provisioned by appliance:** The device can only be initially provisioned against an appliance. Error code: `APPLIANCE_ONLY`&#x20;
* **Duplicate HW ID:** The hardware ID provided in the PR matches an existing device's hardware ID, and does not meet your organization's PR approval policy. Error code: `DUPLICATE_HW_ID_FAILURE`
* **Missing PR signer key:** The key used to sign the PR either does not exist or is not yet available to verify the PR. Error code: `MISSING_PR_SIGNER_KEY`
* **Malformed PR signature**: The signature of the PR did not meet expectations and could not be verified. Error code: `PR_SIGNATURE_MALFORMED`
* **Max instances exceeded:** The maximum number of this device (component) has already been reached, as defined in your system definition. Error code: `MAX_INSTANCE_FAILURE`

### Vault errors

* **Vault could not sign certificates:** Vault was unable to sign device certificates. Error code: `FAIL_SIGN_DEVICE_CERTIFICATES`
* **Vault could not sign profile:** Vault was unable to sign a device certified profile. Error code: `FAIL_SIGN_DEVICE_CERTIFIED_PROFILE`
* **Vault request timed out:** Our service that drives provisioning timed out making a request to Vault. Error code: `VAULT_REQUEST_TIMEOUT`
* **Vault could not find PR signer:** Vault could not find the device identity of the device that signed the PR. Error code: `UNABLE_LOOKUP_PROVISION_REQUEST_SIGNER`
* **Vault could not find device leaf certificates:** Vault could not find device leaf certificates for a device. Error code: `UNABLE_LOOKUP_DEVICE_CERTIFICATES`
* **Vault could not find vault signer certificate:** Vault was unable to find the certificate of a vault signer. Error code: `FAIL_SIGN_MISSING_SIGNER_CERTIFICATE`

### Reprovisioning errors

Some errors can only occur when reprovisioning a device.

* **Component mismatch:** The PR contains a different component name than the component that signed the PR. Error code: `REPROVISIONING_MISMATCH_COMPONENT`
* **HW ID mismatch:** The PR has a different hardware ID than the device that signed the PR. Error code: `REPROVISIONING_MISMATCH_HARDWARE_IDENTIFIER`
* **Instance mismatch:** The PR is for a device in a different system instance than the device that signed the PR. Error code: `REPROVISIONING_MISMATCH_INSTANCE`
* **Device is already provisioning:** The PR is a re-provision request for a device that is in the process of provisioning. Error code: Error code: `REPROVISIONING_PROVISIONING_COMPONENT`

## Filter devices

You can filter on system, device, and provisioning information.

**General section**

* **System name:** Select the main system to view. This is also known as the system definition.
* **System instance:** Select one or more system instances to view.
* **Component name:** Select one or more components to view.
* **Device hardware ID:** Specify a particular device hardware ID to filter on.

**Provisioning details section**

* Toggle to view current provisioning status for all devices or all statuses the devices have moved through.
* **Provisioning status:** Select one or more provisioning status(es). The available statuses will depend on the approval type of the system you are currently viewing.
* **Provisioned on:** Select a date range to view devices that moved to the **Provisioned** status during that time.

## Export provisioning report

You can either export the current provisioning status for all devices or select the devices you want to export the latest provisioning status for.&#x20;

1. To export all devices, select **Export** drop-down in the toolbar. In the **All devices** group, select **Device provisioning report**.
2. To export selected devices, select the devices you want to export the status for, then select **Export** drop-down in the toolbar. In the **Selected devices** group, select **Device provisioning report**. This will export the device provisioning report in CSV format.


# Manage certificates

{% hint style="warning" %}
🚧 This feature is currently in development.
{% endhint %}

You can view device certificate status and revoke root and intermediate certificates, as well as all certificates for a particular device. You can export your Certificate Revocation List (CRL) for all devices from the **Provisioning** tab.

## Select system

1. Click the **Devices** item in the sidebar. This will display the **Devices** page, which consists of two tabs,  **Provisioning** and **Certificates**.&#x20;
2. Select a system name from the **System name** drop-down on the page. You can also narrow down results by selecting **System instance** or **Component name** from these drop-downs.&#x20;
   * Alternately, you can select a system name from the Select system name drop-down in the breadcrumb trail.&#x20;
   * You can currently only select one system name. [Contact us](mailto:support@medcrypt.co) if you need to view multiple systems simultaneously.
3. Click the **Certificates** tab. This will display all certificates for the selected system.
4. Click the **Filters** drop-down to filter on system instance, component, and other criteria.

## Certificates

Each certificate card displays on the right under the filter bar. By default, the first certificate in the list is selected. The current selection is indicated by a blue background and a blue selection bar on the far left of the card.&#x20;

### Certificate types

Guardian can use two types of certificates to secure devices:&#x20;

* **Standard x.509 certificates:** This is the certificate type used in our out-of-the-box system configurations.
* **Medcrypt-proprietary certificates:** We also can provide our proprietary certificates that are specifically designed for medtech use cases such as memory constraints.

### Certificate statuses

* **Pending validation:** This certificate has not yet been validated.
* **Active:** This certificate is active and is not nearing expiration.
* **Expired:** This certificate has expired and needs to be replaced.
* **Expires (timeframe):** This certificate is nearing its expiration date and should be replaced soon. It is currently still active. It indicates the number of days, weeks, or months until a certificate expires. Any certificate that expires in under 6 months will display this status.
* **Suspended:** This certificate has been suspended.
* **Revoked:** This certificate has been revoked. View the certificate details to see the reason for revocation.

### Certificate details

All certificates have standard x.509 fields. The exception is for device-level certificates, which have additional system details, provisioning details, and a **Medcrypt certificate attributes** section for context.&#x20;

**View certificate details and children**

1. Click any certificate to view its details. You can click the certificate card itself or its details icon.&#x20;
2. Root and intermediate certificates that have children will have a drop-down arrow. You can click each arrow to expand certificates individually or click the **expand all** icon to expand all parent certificates automatically.

<details>

<summary><strong>System details</strong></summary>

* **System name:** This is the system definition. It will also be referred to as system.
* **System instance name:** This is a particular instance of the system name.
* **Component name:** This is a component in the system instance.
* **Component instance ID:** This is the unique ID for a component.
* **Device HW ID:** This is the unique ID for a device.&#x20;
* **System instance ID:**
* **Component instance ID:** This is the unique ID for a component.
* **Component instance created on:** This is when the component instance was created.

</details>

<details>

<summary><strong>Provisioning details</strong></summary>

* **Provisioning status:** This shows the provisioning status of the PR. Statuses will depend on your system's defined approval type.
* **Approved on / by:** This is the date the provisioning request was approved, as well as whether it was automatically approved (System) or manually approved (user name).
* **Rejected on / by:** This is the date the provisioning request was rejected, as well as who rejected it.
* **Error code:** For systems using the automatic approval workflow, this will display a particular error code. Refer to [troubleshooting device provisioning](/manage-devices/manage-device-provisioning#troubleshooting) for more information.
* **Provisioned on / by:** This is the date the device provisioning was completed, as well as who provisioned it.

</details>

<details>

<summary><strong>Identity</strong></summary>

* Common name (CN)
* Organization name (O)
* Subject alt name (SAN): This is only shown for device-level certificates

</details>

<details>

<summary><strong>Status &#x26; validity</strong></summary>

* **Status:** This indicates the current status of a certificate.
* Not before: This also shows the date and relative time until the certificate is valid.
* Not after: This also shows the relative time until the certificate is no longer valid. If the certificate has expired, this shows the time elapsed, such as (x days ago).
* Validity period
* **Revoked on / by:** This is the date when the certificate was revoked and who it was revoked by.
* **Revocation reason:** This shows the reason the certificate was revoked.

</details>

<details>

<summary><strong>Security</strong></summary>

* TLS pinning
* Key type
* Signature algorithm

</details>

<details>

<summary><strong>Additional identity information</strong></summary>

* Organizational unit (OU)
* Email address (E)

</details>

<details>

<summary><strong>Location</strong></summary>

* Country (C)
* State/Province (ST or S)
* Locality/City (L)

</details>

#### Technical details section

<details>

<summary><strong>Key usage</strong></summary>

* Critical
* Permitted uses
* Serial number

</details>

<details>

<summary><strong>Basic constraints</strong></summary>

* Critical
* Certificate authority
* Path length constraint

</details>

<details>

<summary>Certificate identifiers</summary>

* Serial number
* Thumbprint
* Authority key identifier
* Subject key identifier

</details>

<details>

<summary><strong>Extended validation</strong></summary>

* CRL distribution points

</details>

<details>

<summary><strong>Medcrypt certificate attributes</strong></summary>

* Component handle
* Environment: This is either TEST or PRODUCTION and is configured when your system was created.
* Expiration action: This is the action that will be automatically performed if a certificate expires.
  * WARN: This will warn you that a certificate has expired.
  * DISABLE: This will automatically disable the certificate
* Guardian hardware ID: This is the UUID or hash in your device that is fed in during device provisioning that represents the Guardian hardware on your device.
* Device hardware ID type: This is always the value, `OCTET STRING`. This can be parsed to get the original hardware ID type.

</details>

## Export certificates

#### Export all certificates

You can export all certificates or filter down to a subset, then export. This will export a zip file containing a .PEM file for each certificate.

#### Export individual certificate

1. Click any certificate to view its details, as well as available actions. This will display the **Certificate details** section.
2. Click the **Export action** link. This will export a .PEM file for this certificate.

## Revoke certificates

Depending on the certificate level, you will have different revoke capabilities.&#x20;

1. Click any certificate to view its details, as well as available actions. This will display the **Certificate details** section.

* **Root or intermediate certificates:** Click the **Revoke certificate action** in the **Certificate details** section.&#x20;
* **Device certificates:** Click the **Revoke all certs for device** action in the **Certificate details** section. If you need the ability to revoke device certificates individually, [let us know](mailto:support@medcrypt.co).

2. In the respective confirmation panel, review the details for each certificate you are revoking.&#x20;
3. For root or intermediate certificates, specify the revocation reason. For device-level certificates, you can specify one revocation reason for all or individual revocation reasons for each certificate.&#x20;

## Filter certificates

All matching items will have a blue highlight background. If root or intermediate certificates are returned, their children are also returned to provide context. These are only highlighted if the child matches the search and filters applied.

### **Search:**&#x20;

In the search box drop-down, you can select **All certificates** or one or more certificate levels, as well as search on the certificate common name.&#x20;

### Filter panel&#x20;

<details>

<summary>System details</summary>

* System name
* System instance name
* Component name:
* Device hardware ID

</details>

<details>

<summary><strong>Provisioning details</strong></summary>

* Provisioning status
* Provisioned on
  * Quick filters selections
  * Date range
* Approved on (date range)
  * Quick filters selections
  * Date range
* Rejected on (date range)
  * Quick filters selections
  * Date range

</details>

<details>

<summary>Certificate details</summary>

You can quickly filter on certificate status and expiration details to proactively manage your certificates.

* Certificate level (root, intermediate, device)
* Certificate status
* Not before
  * Quick filters selections
  * Date range
* Not after&#x20;
  * Quick filters selections
  * Date range
* Revocation reason
* Revoked on:
  * Quick filters selections
  * Date range

</details>

## Filter certificates

You can filter on system, device, and certificate information.

**General section**

* **System name:** Select the main system to view. This is also known as the system definition.
* **System instance:** Select one or more system instances to view.
* **Component name:** Select one or more components to view.
* **Device hardware ID:** Specify a particular device hardware ID to filter on.

**Provisioning details section**

* Toggle to view current provisioning status for all devices or all statuses the devices have moved through.
* **Provisioning status:** Select one or more provisioning status(es). The available statuses will depend on the approval type of the system you are currently viewing.
* **Provisioned on:** Select a date range to view devices that moved to the **Provisioned** status during that time.

**Certificate sections**

You can filter on device certificates, device leaf certificates, and intermediate certificates in their respective sections.&#x20;

* **Certificate status:** Select one or more provisioning status(es) for each certificate type you want to filter on.&#x20;
* **Expires on:** Select a date range to view which certificates will expire during that time.
* **Revocation reason**: Select one or more revocation reasons to filter on. This filter conditionally displays if you select the **Revoked** certificate status.
* **Revoked on:** Select a date range to view which certificates were revoked during that time. This filter conditionally displays if you select the **Revoked** certificate status.

**Medcrypt certificates section:**<br>

* Component handle \[text field]
* Environment
* Expiration action

## Change date formatting

By default, device provisioning data is displayed in UTC time and in **dd mmm yyyy** format. You can change this to display ISO format and/or to show dates in your local time.

1. To change the date formatting, click the **Settings** drop-down in the toolba&#x72;**.**
2. Toggle the respective date settings, which will automatically apply.

## FAQ

#### How will we know when certificates expire?

You can filter on certificate status and expiration date, as well as view details for any certificate.&#x20;


# Extract certificates from provisioned devices

## Extract certificates via API

Extracting keys and certificates through the Guardian API consists of using the Guardian Library to complete the two certificate and key extraction steps.

### **C# example**

```csharp
public static void GetKeyAndCerts()
{
    medcrypt.guardian.InitializeFiles initializeFiles =
        new medcrypt.guardian.InitializeFiles();

    /* read provisioned files into file structure */
    initializeFiles.trustStore =
        File.ReadAllBytes(@"TrustStore.mcts");
    initializeFiles.privateIdentity =
        File.ReadAllBytes(@"PrivateIdentity.mcpi");
    initializeFiles.certifiedProfile =
        File.ReadAllBytes(@"CertifiedProfile.mcp");

    /* customer data about the provisioning system */
    string componentHandle = "my_component_handle";
    string hardwareId = "my_serial_number";
    string serviceName = "my_service_name";

    /* accept input options, or create default */
    medcrypt.guardian.InitializeOptions options =
       new medcrypt.guardian.InitializeOptions();

    /* initialize guardian for configured operations (key and cert)*/
    medcrypt.guardian.Guardian gdn = new medcrypt.guardian.Guardian();

    gdn.Initialize(
        initializeFiles,
        componentHandle,
        hardwareId,
        new medcrypt.guardian.InitializeOptions());

    List<byte[]> certs = null;
    byte[] key = null;

    medcrypt.guardian.IService service = gdn.FindService(serviceName);

    /* get key  */
    key = service.GetCertificateKey(KeyFormat.PKCS8_PEM);

    /* get length of certificate chain, and add all certs to output
        list */
    ulong chainLen = service.GetCertificateChainLength();
    certs = new List<byte[]>();
    for (ulong i = 0; i < chainLen; i++)
    {
        certs.Add(service.GetCertificate(i, CertFormat.PEM));
    }
}
```

### **C++ example**

```cpp
#include "medcrypt/guardian/GuardianSystem.h"
#include "medcrypt/guardian/Utilities/Files/FileHelpers.h"

#define MSG(x) { printf x; printf("\n"); }
#define MSG_INFO(x) { MSG(x); }
#define MSG_ERROR(x) { printf("ERROR: "); MSG(x); }
#define MSG_WARNING(x) { printf("WARNING: "); MSG(x); }
#define ARBITRARY_KEY_SIZE 128
#define ARBITRARY_CERT_SIZE 3 * 1024

bool GetKeyAndCerts()
{
    medcrypt::guardian::Status status;
    medcrypt::guardian::utilities::InitializeFiles in_files;
    std::string in_component_handle = "my_component_handle";
    std::string in_hardware_id = "my_serial_number";
    std::string in_provisioning_profile_folder =
        "/path/to/provisioned/profile/folder/";
    std::string in_service_name = "my_service_name";

    /* initialize provided guardian */
    medcrypt::guardian::Guardian guardian;
    status = guardian.Initialize(
        in_files,
        in_component_handle.c_str(),
        in_hardware_id.c_str(),
        medcrypt::guardian::InitializeOptions());

    /* check and print non OK error code */
    if (EXTRACT_STATUS(status) != medcrypt::guardian::GuardianStatusEnum::OK) {
        MSG_ERROR(("could not initialize guardian [%s]",
            medcrypt::guardian::GuardianStatusEnum::NameOf(
                EXTRACT_STATUS(status)).c_str()));
        return false;
    }

    std::unique_ptr<medcrypt::guardian::Service> service;
    /* find desired service by name */
    status = guardian.FindService(in_service_name.c_str(), &service);

    /* check and print non OK error code */
    if (EXTRACT_STATUS(status) != medcrypt::guardian::GuardianStatusEnum::OK) {
        MSG_ERROR(("could not find service [%s] [%s]",
            in_service_name.c_str(),
            medcrypt::guardian::GuardianStatusEnum::NameOf(
                EXTRACT_STATUS(status)).c_str()));
        return false;
    }

    std::list<std::vector<char>> io_certs;
    std::vector<unsigned char> io_key;

    io_key.assign(ARBITRARY_KEY_SIZE, '\0');
    size_t size = io_key.size();

    /* retrieve pkcs8 encoded key */
    status = service->GetCertificateKey(io_key.data(), &size);
    if (EXTRACT_STATUS(status) != medcrypt::guardian::GuardianStatusEnum::OK) {
        MSG_ERROR(("could not retrieve key [%s]",
            medcrypt::guardian::GuardianStatusEnum::NameOf(
                EXTRACT_STATUS(status)).c_str()));
        return false;
    }
    io_key.resize(size);

    /* retrieve any available certs from the cert chain */
    size_t chain_length = service->GetCertificateChainLength();
    io_certs.clear();
    for (size_t i = 0; i < chain_length; i++) {
        io_certs.emplace_back();
        size = service->GetCertificateSize(i);
        io_certs.back().assign(size, '\0');

        /* retrieve certificate */
        status = service->GetCertificate(
            i,
            io_certs.back().data(),
            &size);

        if (EXTRACT_STATUS(status) != medcrypt::guardian::GuardianStatusEnum::OK) {
            MSG_ERROR(("could not retrieve cert [%u] [%s]",
                (unsigned int)i,
                medcrypt::guardian::GuardianStatusEnum::NameOf(
                    EXTRACT_STATUS(status)).c_str()));
            return false;
        }
    }

    return true;
}
```

###

### C example

```c
#define MAX_GDN_SIZE 15 * 1024 /* increase as necessary, this memory does not have to be on the stack */
#define ARBITRARY_BUF_SIZE 5 * 1024 /* increase as necessary */
#define ARBITRARY_KEY_SIZE 128
#define ARBITRARY_CERT_SIZE 3 * 1024
#define LEAF_CERT_IDX 0

/* Setup example write callback to be used by guardian streams */
static bool sample_callback(mcg_guardian_ostream_t *stream,
                            const uint8_t *buf,
                            size_t count)
{
    size_t i;
    uint8_t *dest = (uint8_t*)stream->state;
    stream->state = dest + count;

    for (i = 0; i < count; i++)
        dest[i] = buf[i];

    return true;
}

static bool get_key_and_certs()
{
    mcg_status status = MCG_STATUS_FAIL;
    mcg_initialize_options_t init_options = {0};
    mcg_initialize_files_t init_files;
    mcg_guardian_istream_t ts, pi, cp;
    size_t cert_chain_path_length = 0;
    size_t cert_chain_length = 0;

    /* create guardian memory region, this memory can come from any source
        but must be a continuous block */
    mcg_memory_t mcg_memory = {NULL, 0, 0};
    uint8_t memory_buffer[MAX_GDN_SIZE] = {0};
    mcg_memory.mem = &memory_buffer[0];
    mcg_memory.size = sizeof(memory_buffer);

    /* customer data about this provisioning system */
    char component_handle[] = "my_component";
    char hardware_id[] = "my_serial_number";
    char service_name[] = "my_service";

    /* read trust store into this buffer, and set in_ts_len to actual size */
    uint8_t in_ts[ARBITRARY_BUF_SIZE] = {0};
    size_t in_ts_len = 1234;

    /* read private identity into this buffer, and set in_pi_len to actual size */
    uint8_t in_pi[ARBITRARY_BUF_SIZE] = {0};
    size_t in_pi_len = 1234;

    /* read certified profile into this buffer, and set in_cp_len to actual size */
    uint8_t in_cp[ARBITRARY_BUF_SIZE] = {0};
    size_t in_cp_len = 1234;

    /* output buffers */
    uint8_t io_key_buf[ARBITRARY_BUF_SIZE] = {0};
    size_t io_key_buf_len = sizeof(io_key_buf);

    uint8_t io_cert_buf[ARBITRARY_BUF_SIZE] = {0};
    size_t io_cert_buf_len = sizeof(io_cert_buf);

    mcg_guardian_ostream_t out_key;
    mcg_guardian_ostream_t out_cert;

    /* Create streams from provided ts/pi/cp byte buffers */
    ts = mcg_istream_from_buffer((const uint8_t*)in_ts, in_ts_len);
    pi = mcg_istream_from_buffer((const uint8_t*)in_pi, in_pi_len);
    cp = mcg_istream_from_buffer((const uint8_t*)in_cp, in_cp_len);

    /* Load streams into mcg_initialize_files_t */
    init_files.trust_store = &ts;
    init_files.private_identity = &pi;
    init_files.certified_profile = &cp;

    status = mcg_gdn_initialize(
        &mcg_memory,
        &init_files,
        component_handle,
        hardware_id,
        &init_options);

    if (status)
    {
        /* Return failure */
        return false;
    }

    /* setup buffer backed key output stream */
    out_key.write_callback = &sample_callback;
    out_key.max_size = io_key_buf_len;
    out_key.bytes_written = 0;
    out_key.state = io_key_buf;

    status = mcg_gdn_write_key(&mcg_memory,
                             service_name,
                             true, /* true = PEM, false = DER */
                             &out_key);
    if (status)
    {
        printf("Failed to write key");
        return false;
    }

    /* setup buffer backed single cert output stream */
    out_cert.write_callback = &sample_callback;
    out_cert.max_size = io_cert_buf_len;
    out_cert.bytes_written = 0;
    out_cert.state = io_cert_buf;

    status = mcg_gdn_write_cert(&mcg_memory,
                        service_name,
                        LEAF_CERT_IDX, /* Note: Only writes a single certificate */
                        true, /* true = PEM, false = DER */
                        &out_cert);

    if (status)
    {
        printf("Failed to write cert");
        return false;
    }

    return true;
}
```

## Extract certificates via command line

This covers how to use a provisioned device to extract pre-arranged keys and certificates from that device's certified profile (CP). Extracting certificates via the command line consists of using the `mcguard_cert_extract` utility to complete the the following certificate and key extraction steps:&#x20;

1. Initialize Guardian with the device's certified profile.
2. Extract key and desired certificates.

* All command line utilities use a working directory approach. During certificate extraction the `mcguard_cert_extract` utility expects to see a `.mcts`, `.mcpip` and `.mcpp` file in the working directory.
* Any argument inside <> brackets should be replaced with the indicated input data (e.g., If the component handle is device1 `<my_component>` , this could be replaced by `device1`).

```bash
# Syntax 
./mcguard_cert_extract --component <my_component> --hardware-id <my_hardwareid> --service <my_service> --key-dir <key_output_dir> --cert-dir <cert_output_dir> <path to provisioned profile>

# Example
./mcguard_cert_extract --component my_device --hardware-id my_device_001 --service my_service --key-dir /home/user/guardian/keys --cert-dir /home/user/guardian/certs /home/user/guardian/provisioned_profile
```


# API overview

## Provisioning functions

### Guardian()

**Description:** Creates new Guardian instance and puts it into startup state, ready for initialization.

* First step before any other operations
* This constructor only initializes member variables

**Dependencies:** None - this is the first function to call

**Parameters:** None - default constructor takes no parameters

**Returns:** Nothing since it is a constructor

**Syntax:**

```cpp
Guardian()
```

### Initialize()

**Description:** Initializes Guardian with device credentials and configuration files. Uses the provided profile, identity, and trust files to initialize the Guardian system.

**Dependencies:**

* Must be called after [creating a Guardian instance](#guardian)  (`Guardian()` constructor).
* Must be called before any other Guardian operations

**Parameters:**&#x20;

* `in_files`: Device credentials and configuration files
* `in_component_handle`: This is the unique component identifier used for provisioning.&#x20;
  * **Type:** `const char*`
* `in_hardware_identifier`: This is the unique hardware identifier.&#x20;
  * **Character limitations:** 36 (37 with null terminator)&#x20;
  * **Type:** `const char*`
* `in_options`: Additional initialization configuration options

**Returns:** Status code indicating success or failure.&#x20;

* **Success code:** `OK`**.** Guardian system was successfully initialized.
* **Error codes:**
  * `FAIL`:  General failure. Guardian did not initialize successfully.  Check the log file for more information.
  * `BADPARAM`: One of the inputs is null or empty.&#x20;
  * `FILENOTFOUND`: A required input file is unavailable.
  * `OUTOFMEMORY` **:** Not enough memory to initialize Guardian.&#x20;

**Syntax**

```cpp
Status Initialize(
    const utilities::InitializeFiles & in_files,
    const char * in_component_handle,
    const char * in_hardware_identifier,
    const InitializeOptions & in_options
)
```

## GenerateProvisionRequest()

**Description:** The  `GenerateProvisionRequest()` function creates provisioning request (`.mcpr`) and private identity (`.mcpi`) files.

* This is the first provisioning step for the provisioning process.&#x20;
* This is the only step in the offline provisioning process.&#x20;
* The private identity (`.mcpi` file) includes the generated device keys. &#x20;
* The provision request (`.mcpr` file) can be manually uploaded to Guardian Cloud or sent using available online methods in the profile.&#x20;

**Dependencies:**

* Must be called after `Initialize()`
* Must be called once before any other provisioning or re-provisioning actions occur.&#x20;
* Required before `StartProvisioningOnline()`

**Parameters:**&#x20;

* &#x20;`io_files` : Provisioning files structure.\
  &#x20;`in_provisioning_component_handle` : This is the unique component identifier used for provisioning.&#x20;
  * **Type:** `const char*`
* &#x20;`in_provisioning_system` : This is the unique system name identifier which is sent to Guardian Cloud.&#x20;
  * **Character limitations:** 36 (37 with null terminator)&#x20;
  * **Type:** `const char*`
* &#x20;`in_hardware_identifier`  - This is the unique hardware identifier.&#x20;
  * **Character limitations:** 36 (37 with null terminator)&#x20;
  * **Type:** `const char*`

**Returns:** Status code indicating success or failure.&#x20;

* **Success code:** `OK`**.** Provisioning request was successfully created
* **Error codes:**
  * `FAIL`:  General failure. Check the log file for more information.&#x20;
  * `BADPARAM`: One of the inputs is null or empty&#x20;
  * `FILENOTFOUND`: A required input file is unavailable&#x20;
  * `NOWRITE`: A required output file could not be written&#x20;
  * `OUTOFMEMORY` : Not enough memory to provision \\

**Syntax**

```cpp
Status GenerateProvisionRequest(
    utilities::ProvisionFiles & io_files,
    const char * in_provisioning_component_handle,
    const char * in_provisioning_system,
    const char * in_hardware_identifier
)
```

## StartProvisioningOnline()

The  `StartProvisioningOnline()` function starts the online provisioning process to submit a provisioning request to Guardian Cloud. It submits the provisioning request and begins the automated processing workflow.

* **Dependencies:** Must be run after GenerateProvisionRequest().
* **Parameters:**
  * `in_files`: Files required for online provisioning
  * `in_options`: Additional optional provisioning configuration options, including timeouts
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` : Online provisioning was successfully started
  * **Error codes:**
    * `FAIL` : General failure starting provisioning.  Check the log file for more information.
    * `BADPARAM` : One of the inputs is null or invalid
    * `FILENOTFOUND` : A required provisioning file is unavailable

**Syntax**

```cpp
Status StartProvisioningOnline(
    const utilities::ProvisionOnlineFiles & in_files,
    const ProvisioningOptions & in_options
)
```

### Run()

* **Description:**&#x20;
  * Executes Guardian background tasks including provisioning state machine processing.&#x20;
  * Includes provisioning, telemetry, handshakes, authentication, services, sessions, and channels that have not been placed or had a parent placed on another thread by [CreateTask](#function-createtask). This should be called by the program/thread's main loop.
  * Must be called regularly and repeatedly during online provisioning.&#x20;
  * Use [IsProvisioningRunning()](#function-isprovisioningrunning) to check when provisioning is complete and stop calling Run().&#x20;
  * Processes internal state machines and handles communication with Guardian Cloud
* **Dependencies:**
  * Must be called after StartProvisioningOnline()
* **Parameters:** No parameters
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` - Background tasks executed successfully
  * **Error codes:**
    * `FAIL` - General failure in background processing.  Check the log file for more information.
    * `SHUTDOWN` : Guardian is in a shutdown state and must be reinitialized before calling run again.&#x20;

### IsProvisioningRunning()

* **Description:** Checks whether the provisioning process is still active.&#x20;
* **Dependencies:**
  * Must be called after StartProvisioningOnline()
  * Used to determine when to stop calling Run() and attempt to retrieve the provisioned profile.
* **Parameters:** None - this function takes no parameters
* **Returns:** Boolean value indicating provisioning status
  * `true` - Provisioning is still in progress. Continue calling Run()
  * `false` - Provisioning has completed (successfully or failed). You should now call GetProvisionedProfile().
  * Before the online provisioning process has started, will return `false`.
  * After online provisioning has either succeeded or failed, will again return `false`.

**Syntax**

```cpp
bool IsProvisioningRunning()
```

### GetProvisionedProfile()

* **Description:**&#x20;
  * Extracts the provisioned profile after successful online provisioning.&#x20;
  * Copies completed provisioned profile to provided buffer.
* **Dependencies:**
  * Must be called only after IsProvisioningRunning() returns `false`.
  * Requires successful completion of StartProvisioningOnline() and Run() loop
* **Parameters:**
  * `out_profile`: Buffer that will receive the provisioned profile.
    * Type: `char`
  * `io_size`:&#x20;
    * Provide size of buffer ( `out_profile` ) on input. After successful provisioning, `out_profile` sets to actual size of profile.
    * Type: `size_t`&#x20;
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` : Provisioned profile successfully retrieved.&#x20;
    * Buffer contains a valid certified profile in  `out_profile` of size `io_size`.&#x20;
  * **Error codes:**
    * `FAIL` : General failure. Check the log file for more information.
    * `INCOMPLETE` : Provisioning process did not complete, thus no profile is available.
    * `BADPARAM` - `out_profile` or `io_size` is null pointer (`nullptr`), or `io_size` is 0
    * `DENIED` - Online provisioning process is still running
    * `FILENOTFOUND` - Provisioning is complete but no provisioned profile is available
    * `BADPARAM` - Buffer or size parameter is invalid&#x20;

**Syntax**

```cpp
Status GetProvisionedProfile(
    char * out_profile,
    size_t * io_size
)
```

## Implementation examples

## Certificate management functions

### GetCertificateManager()

* **Description:** Retrieves the certificate manager for handling device certificates. Provides access to certificate operations and lifecycle management.
* **Dependencies:**
  * Can optionally be called after Initialize()
* **Parameters:**
  * `out_certificate_manager`: Output pointer to receive the certificate manager instance
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` :&#x20;
    * Certificate manager successfully retrieved
    * The pointer in `out_certificate_manager` is valid&#x20;
  * **Error codes:**
    * `FAIL` : General failure. Check the log file for more information.
    * `BADPARAM` : `out_certificate_manager` is a null pointer and cannot be filled
    * `DENIED` : Guardian is not initialized
    * `MISCONFIGURED` : The loaded provisioned profile is not configured to allow certificate operations.
* **Action:**&#x20;
  * Use the retrieved certificate manager to import and export certificates.

**Syntax**

```cpp
Status GetCertificateManager(
    std::unique_ptr< CertificateManager > * out_certificate_manager
)
```

### GetProvisionedRevocationList()

* **Description:**&#x20;
  * Retrieves the certificate revocation list (CRL) for checking certificate validity.&#x20;
  * Used to identify revoked certificates that should no longer be trusted.
* **Dependencies:**
  * Can optionally be called after successful provisioning (after GetProvisionedProfile())
* **Parameters:**
  * `out_ccrl`: Buffer to receive the certificate revocation list
    * Type: `char*`
  * `io_size`: Size of buffer on input, actual size on output
    * Provide size of buffer ( `out_ccrl` ) on input. After successful provisioning, `out_ccrl` sets to actual size of CRL.
    * Type: `size_t`&#x20;
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK`&#x20;
    * &#x20;`out_ccrl` has a valid revocation list of size `io_size`
  * **Error codes:**
    * `FAIL` - General failure. Check the log file for more information.
    * `INCOMPLETE` - Provisioning process did not complete, no revocation list available
    * `BADPARAM` : `out_ccrl` or `io_size` is null pointer, or `io_size` is 0
    * `DENIED` - Online provisioning process is still running
    * `FILENOTFOUND` - Provisioning is complete but no revocation list is available
* **Action:** Copies certificate revocation list to provided buffer

**Syntax**

```cpp
Status GetProvisionedRevocationList(
    char * out_ccrl,
    size_t * io_size
)
```

## Security operations function

### FindSecureOperation()

* **Description:**&#x20;
  * Perform lookup for secure operation name.&#x20;
  * Get secure operation handler for signing and verification operations.
* **Dependencies:**
  * Can optionally be called after Initialize()
* **Parameters:**
  * `in_secureop_name`: Secure operation name, terminated by null.
    * **Type**: `const char*`
  * `out_secureop`: Pointer to `unique_ptr` storage for located secure operation
* **Returns:** Status code indicating success or failure.
* **Success code:** `OK` : The pointer in `out_secureop` is valid
* **Error codes:**
  * `FAIL` : Could not find the operation specified by `in_secureop_name`
  * `BADPARAM` : `out_secureop` is null pointer and cannot be filled
  * `DENIED` : Guardian is not initialized
* **Action:**&#x20;
  * Sets `out_secureop` to the located operation
  * Will not modify `out_secureop` if the operation `in_secureop_name` is not located

**Syntax**

```cpp
Status FindSecureOperation(
    const char * in_secureop_name,
    std::unique_ptr< SecureOperation > * out_secureop
)
```

## Service management functions

### FindService()

* **Description:**
  * Performs lookup for service name to locate a configured service.
* **Dependencies:**
  * Must be called after Initialize()
* **Parameters:**
  * `in_service_name`: Service name, terminated by null
    * **Type:** `const char*`
  * `out_service`: Pointer to unique\_ptr storage for found service
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` : The pointer in `out_service` is valid
  * **Error codes:**
    * `FAIL` : Could not find the service specified by `in_service_name`
    * `BADPARAM` : `out_service` is null pointer and cannot be filled
    * `DENIED` : Guardian is not initialized
* **Action:**&#x20;
  * Sets `out_service` to the located service&#x20;
  * Will not modify `out_service` if the service in `in_service_name` is not located
  * or leaves unmodified if the service is not found

**Syntax**

```cpp
Status FindService(
    const char * in_service_name,
    std::unique_ptr< Service > * out_service
)
```

### **CreateTask() - Service variant**

* **Description:**
  * Create a task for service operations that separates the provided object and all children from Run.
  * Allows for threading of separate objects by removing them from the main Guardian Run loop.
* **Dependencies:**
  * Must be called after Initialize()
  * Service object must be valid
* **Parameters:**
  * `io_service`: Service component to place on a thread, will be consumed on success, unmodified on failure
  * `out_task`: Pointer to unique\_ptr storage for the task
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` : out\_task has a valid task
  * **Error codes:**
    * `FAIL` : General failure. Check the log file for more information.
    * `BADPARAM` : io\_service or out\_task is null pointer
    * `DENIED` : Specified service is already in a task
* **Action:** A component placed on a Task along with all children will not run when Guardian Run is called, allowing for threading of separate objects

**Syntax**

```cpp
Status CreateTask(
    std::unique_ptr< Service > * io_service,
    std::unique_ptr< Task > * out_task
)
```

### CreateTask() - Session variant

* **Description:**
  * Create a task for service operations that separates the provided object and all children from Run.
  * Allows for threading of separate objects by removing them from the main Run loop.
* **Dependencies:**
  * Can optionally be called after Initialize()
  * Service object must be valid
* **Parameters:**
  * `io_service`: Service component to place on a thread. This will be consumed on success, but not modified if not successful.
  * `out_task`: Pointer to `unique_ptr` storage for the task
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` : `out_task` has a valid task
  * **Error codes:**
    * `FAIL` : General failure. Check the log file for more information.
    * `BADPARAM` : `io_service` or `out_task` is null pointer
    * `DENIED` : Specified service is already in a task
* **Action:**&#x20;
  * A component placed on a Task along with all children will not run when Run is called, allowing for threading of separate objects.
  * To return an object to the main `Run` loop, destroy the `unique_ptr`.

**Syntax**

```cpp
Status CreateTask(
    std::unique_ptr< Session > * io_session,
    std::unique_ptr< Task > * out_task
)
```

### CreateTask() - ChannelGuard Variant

* **Description:**
  * Create a task for channel operations that separates the provided object and all children from Run().
  * Allows for threading of separate objects by removing them from the main Run() loop.
* **Dependencies:**
  * Must be called after Initialize()
  * `ChannelGuard` object must be valid
* **Parameters:**
  * `io_channelguard`: `ChannelGuard` component to place on a thread
  * `out_task`: Pointer to `unique_ptr` storage for the task
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` : `out_task` has a valid task
  * **Error codes:**
    * `FAIL` : General failure. Check the log file for more information.
    * `BADPARAM` : `io_channelguard` or `out_task` is null pointer
    * `DENIED` : Specified `ChannelGuard` is already in a task and has not been returned
* **Action:**&#x20;
  * A component placed on a Task along with all children will not run when Run() is called, allowing for threading of separate objects.
  * To return an object to the main Run() loop, destroy the unique\_ptr.

**Syntax**

```cpp
Status CreateTask(
    std::unique_ptr< ChannelGuard > * io_channelguard,
    std::unique_ptr< Task > * out_task
)
```

## **System management functions**

### GetAuthenticationManager()

* **Description:**
  * Retrieve the running authentication manager.
  * Provides access to authentication operations and allow/deny lists for user-managed connections.
* **Dependencies:**
  * Can optionally be called after Initialize()
* **Parameters:**
  * `out_authentication_manager`: Pointer to `unique_ptr` storage for authentication manager
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` : The pointer in `out_authentication_manager` is valid
  * **Error codes:**
    * `FAIL` : General failure. Check the log file for more information.
    * `BADPARAM` : `out_authentication_manager` is null pointer and cannot be filled
    * `DENIED` : Guardian is not initialized
    * `MISCONFIGURED` : The loaded profile is not configured to allow external authentication operations
* **Action:** Use the retrieved authentication manager to get allow/deny lists for user managed connections

**Syntax**

```cpp
Status GetAuthenticationManager(
    std::unique_ptr< AuthenticationManager > * out_authentication_manager
)
```

### GetTelemetryManager()

* **Description:**
  * Retrieve the running telemetry manager.
  * Provides access to telemetry service interactions.
* **Dependencies:**
  * Can optionally be called after Initialize()
* **Parameters:**
  * `out_telemtry_manager`: Pointer to `unique_ptr` storage for telemetry manager
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` : The pointer in `out_telemtry_manager` is valid
  * **Error codes:**
    * `FAIL` : General failure. Check the log file for more information.
    * `BADPARAM` : `out_telemtry_manager` is null pointer and cannot be filled
    * `DENIED` : Guardian is not initialized or there is no telemetry manager running
    * `MISCONFIGURED` : The loaded profile is not configured for telemetry
* **Action:** Use the retrieved telemetry manager to interact with the telemetry service

**Syntax**

```cpp
Status GetTelemetryManager(
    std::unique_ptr< Telemetry > * out_telemtry_manager
)
```

### \~Guardian()

* **Description:** The destructor attempts a graceful shutdown of Guardian.
* **Dependencies:** None - destructor is automatically called when object goes out of scope or is explicitly deleted
* **Parameters:** None - destructor takes no parameters
* **Returns:** Nothing since it is a destructor.
* **Action:** The destructor will attempt to call Shutdown() for a graceful shutdown, then Guardian will destruct.

**Syntax**

```cpp
~Guardian()
```

### Shutdown()

* **Description:**
  * Attempts to stop all internal state machines, shutting down Guardian.
  * Includes provisioning, telemetry, handshakes, authentication, services, sessions, and channels, INCLUDING those that have been placed or had a parent placed on another thread by [CreateTask](#createtask-service-variant).
* **Dependencies:**
  * Can optionally be called after Initialize()
  * If there is data waiting to be sent it will return a failure code or require `in_force`
* **Parameters:**
  * `in_force`: Drop all queued send data and shut down. Default value is `false`.
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` : Guardian is shut down successfully
  * **Error codes:**
    * `FAIL` : General failure. Check the log file for more information.
    * `AGAIN` : One or more transports has queued data to send&#x20;
* **Action:** Stops all internal state machines including provisioning, telemetry, handshakes, authentication, services, sessions, and channels.

**Syntax**

```cpp
Status Shutdown(
    const bool & in_force =false
)
```

The [medcrypt namespace ](/api-reference/api-reference/namespaces/namespacemedcrypt)contains the [guardian namespace](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian), which includes the following classes and structures.

## **Core classes**

* [Guardian](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian) class:&#x20;
  * **Description:** Root of Guardian system.&#x20;
  * **Location:** medcrypt::guardian::Guardian
* [AuthenticationManager](/api-reference/api-reference/classes/classmedcrypt-guardian-authenticationmanager) class:&#x20;
  * **Description:** Container for authentication restrictions.&#x20;
  * **Location:** medcrypt::guardian::AuthenticationManager
* [ChannelGuard](/api-reference/api-reference/classes/classmedcrypt-guardian-channelguard) class:&#x20;
  * **Description:** Name channel within a [Session](/api-reference/api-reference/classes/classmedcrypt-guardian-session).&#x20;
  * **Location:** medcrypt::guardian::ChannelGuard
* [SecureOperation](/api-reference/api-reference/classes/classmedcrypt-guardian-secureoperation) class:&#x20;
  * **Description:** Named standalone operation.&#x20;
  * **Location:** medcrypt::guardian::SecureOperation
* [Service](/api-reference/api-reference/classes/classmedcrypt-guardian-service) class:&#x20;
  * **Description:** Named group of connection and channel configurations.
  * **Location:** medcrypt::guardian::Service
* [Session](/api-reference/api-reference/classes/classmedcrypt-guardian-session) class:&#x20;
  * **Description:** Individual connection within a [Service](/api-reference/api-reference/classes/classmedcrypt-guardian-service).
  * **Location:** medcrypt::guardian::Session
* [Task](/api-reference/api-reference/classes/classmedcrypt-guardian-task) class:&#x20;
  * **Description:** Multithreading container.&#x20;
  * **Location:** medcrypt::guardian::Task
* [TransportInterface](/api-reference/api-reference/classes/classmedcrypt-guardian-transportinterface) class:&#x20;
  * **Description:** [ConfigureTransport()](/api-reference/api-reference/classes/classmedcrypt-guardian-service#function-configuretransport) required interface.&#x20;
  * **Location:** medcrypt::guardian::TransportInterface

## **Data structures**

* [AuthenticationDomain](/api-reference/api-reference/classes/structmedcrypt-guardian-authenticationdomain) struct:&#x20;
  * **Description:** Authentication restriction container. Restrictions for use by an authentication agent.&#x20;
  * **Location:** medcrypt::guardian::AuthenticationDomain
* [InitializeOptions](/api-reference/api-reference/classes/structmedcrypt-guardian-initializeoptions) struct:&#x20;
  * **Description:** Options used by [Initialize()](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-2-run-initialize) during setup.&#x20;
  * **Location:** medcrypt::guardian::InitializeOptions
* [ProvisioningOptions](/api-reference/api-reference/classes/structmedcrypt-guardian-provisioningoptions) struct:&#x20;
  * **Description:** Options used by [StartProvisioningOnline()](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-4-startprovisioningonline).&#x20;
  * **Location:** medcrypt::guardian::ProvisioningOptions

### Utility namespace & structures

The [guardian namespace](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian) also includes the [utilities](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities) namespace, which includes the following structures:

* [InitializeFiles](/api-reference/api-reference/classes/structmedcrypt-guardian-utilities-initializefiles) struct:&#x20;
  * **Description:** Storage for initialization files used by [Initialize()](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-2-run-initialize).&#x20;
  * **Location:** medcrypt::guardian::utilities::InitializeFiles
* [ProvisionFiles](/api-reference/api-reference/classes/structmedcrypt-guardian-utilities-provisionfiles) struct:&#x20;
  * **Description:** Storage for generating provision request files in [GenerateProvisionRequest()](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-3-run-generateprovisionrequest).&#x20;
  * **Location:** medcrypt::guardian::utilities::ProvisionFiles
* [ProvisionOnlineFiles](/api-reference/api-reference/classes/structmedcrypt-guardian-utilities-provisiononlinefiles) struct:
  * **Description:** Storage for online provisioning files in [StartProvisioningOnline()](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-4-startprovisioningonline).
  * **Location:** medcrypt::guardian::utilities::ProvisionOnlineFiles

## **Other namespaces**

* [AuthenticationAllowDenyEnum](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-authenticationallowdenyenum)  namespace:&#x20;
  * **Description:** Determines whether a specified list is in an allow or deny list.
  * **Location:** medcrypt::guardian::AuthenticationAllowDenyEnum
* [GuardianStatusEnum](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum) namespace:
  * **Description:** Status codes returned by Guardian functions.
  * **Location:** medcrypt::guardian::GuardianStatusEnum
* [LogLevelEnum](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-loglevelenum) namespace:
  * **Description:** Log levels returned by Guardian functions.&#x20;
  * **Location:** medcrypt::guardian::LogLevelEnum


# API reference

## Frequently Used References

{% content-ref url="/pages/-MD0rw0qMat4rv0A8KkC" %}
[medcrypt::guardian::Guardian](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian)
{% endcontent-ref %}

{% content-ref url="/pages/-MD0rw0rvf8xwC5NyFm3" %}
[medcrypt::guardian::Service](/api-reference/api-reference/classes/classmedcrypt-guardian-service)
{% endcontent-ref %}

{% content-ref url="/pages/-MD0rw0swjxc7ttgDQEp" %}
[medcrypt::guardian::Session](/api-reference/api-reference/classes/classmedcrypt-guardian-session)
{% endcontent-ref %}

{% content-ref url="/pages/-MD0rw0tIPg5W3RM6Lnr" %}
[medcrypt::guardian::ChannelGuard](/api-reference/api-reference/classes/classmedcrypt-guardian-channelguard)
{% endcontent-ref %}

{% content-ref url="/pages/-MD0rw0ukks2kY9K3ns-" %}
[medcrypt::guardian::SecureOperation](/api-reference/api-reference/classes/classmedcrypt-guardian-secureoperation)
{% endcontent-ref %}


# Namespaces

* **namespace** [**medcrypt**](/api-reference/api-reference/namespaces/namespacemedcrypt)&#x20;
  * **namespace** [**guardian**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian)&#x20;
    * **namespace** [**AuthenticationAllowDenyEnum**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-authenticationallowdenyenum)&#x20;
    * **namespace** [**GuardianStatusEnum**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum)&#x20;
    * **namespace** [**LogLevelEnum**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-loglevelenum)&#x20;
    * **namespace** [**utilities**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities)&#x20;


# medcrypt

## Namespaces

| Name                                                                                         |
| -------------------------------------------------------------------------------------------- |
| [**medcrypt::guardian**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian) |


# medcrypt::guardian

## Namespaces

| Name                                                                                                                                                  |
| ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| [**medcrypt::guardian::AuthenticationAllowDenyEnum**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-authenticationallowdenyenum) |
| [**medcrypt::guardian::GuardianStatusEnum**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum)                   |
| [**medcrypt::guardian::LogLevelEnum**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-loglevelenum)                               |
| [**medcrypt::guardian::utilities**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities)                                     |

## Classes

|        | Name                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| struct | <p><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-AuthenticationDomain.md"><strong>medcrypt::guardian::AuthenticationDomain</strong></a> <br>Authentication restriction container. Restrictions for use by an authentication agent.</p>                                                                                                                                    |
| class  | <p><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-AuthenticationManager.md"><strong>medcrypt::guardian::AuthenticationManager</strong></a> <br>Container for authentication restrictions.</p>                                                                                                                                                                               |
| class  | <p><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-ChannelGuard.md"><strong>medcrypt::guardian::ChannelGuard</strong></a> <br>Name channel within a <a href="/api-reference/api-reference/namespaces/namespacemedcrypt-guardian">Session</a>.</p>                                                                                                                            |
| class  | <p><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-Guardian.md"><strong>medcrypt::guardian::Guardian</strong></a> <br>Root of guardian system.</p>                                                                                                                                                                                                                           |
| struct | <p><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-InitializeOptions.md"><strong>medcrypt::guardian::InitializeOptions</strong></a> <br>Options used by <a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-Guardian.md#function-initialize">Guardian::Initialize</a>.</p>                               |
| struct | <p><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-ProvisioningOptions.md"><strong>medcrypt::guardian::ProvisioningOptions</strong></a> <br>Options used by <a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-Guardian.md#function-startprovisioningonline">Guardian::StartProvisioningOnline</a>.</p> |
| class  | <p><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-SecureOperation.md"><strong>medcrypt::guardian::SecureOperation</strong></a> <br>Named standalone operation.</p>                                                                                                                                                                                                          |
| class  | <p><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-Service.md"><strong>medcrypt::guardian::Service</strong></a> <br>Named group of connection and channel configurations.</p>                                                                                                                                                                                                |
| class  | <p><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-Session.md"><strong>medcrypt::guardian::Session</strong></a> <br>Individual connection within a <a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-Service.md">Service</a>.</p>                                                                       |
| class  | <p><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-Task.md"><strong>medcrypt::guardian::Task</strong></a> <br>Multithreading container.</p>                                                                                                                                                                                                                                  |
| class  | <p><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-TransportInterface.md"><strong>medcrypt::guardian::TransportInterface</strong></a> <br><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-Service.md#function-configuretransport">Service::ConfigureTransport</a> required interface.</p>             |

## Types

|                   | Name                                                                                            |
| ----------------- | ----------------------------------------------------------------------------------------------- |
| typedef uint32\_t | [**Status**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian#typedef-status) |

## Types Documentation

### typedef Status

```cpp
typedef uint32_t medcrypt::guardian::Status;
```


# medcrypt::guardian::AuthenticationAllowDenyEnum

## Types

|      | Name                                                                                                                                         |
| ---- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| enum | [**Type**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-authenticationallowdenyenum#enum-type) { Allow = 0, Deny = 1 } |

## Functions

|                                                                                                                  | Name                                                                                                                                                                                                                                                            |
| ---------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| std::string                                                                                                      | [**NameOf**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-authenticationallowdenyenum#function-nameof)(const [Type](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-authenticationallowdenyenum#enum-type) & in\_enum) |
| [Type](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-authenticationallowdenyenum#enum-type) | [**Enum**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-authenticationallowdenyenum#function-enum)(const std::string & in\_string)                                                                                                        |
| bool                                                                                                             | [**IsValid**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-authenticationallowdenyenum#function-isvalid)(const int & in\_value)                                                                                                           |

## Types Documentation

### enum Type

| Enumerator | Value | Description                                               |
| ---------- | ----- | --------------------------------------------------------- |
| Allow      | 0     | specified list is an allow list, an empty list blocks all |
| Deny       | 1     | specified list is a deny list, an empty list allows all   |

## Functions Documentation

### function NameOf

```cpp
std::string NameOf(
    const Type & in_enum
)
```

### function Enum

```cpp
Type Enum(
    const std::string & in_string
)
```

### function IsValid

```cpp
bool IsValid(
    const int & in_value
)
```


# medcrypt::guardian::GuardianStatusEnum

## Types

|      | Name                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| enum | [**Type**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum#enum-type) { OK = 0x00, FAIL = 0x01, BADPARAM = 0x02, MISCONFIGURED = 0x03, INCOMPLETE = 0x04, DENIED = 0x05, BADINIT = 0x06, PROTOCOL = 0x07, OUTOFMEMORY = 0x08, VERIFYFAIL = 0x09, FILENOTFOUND = 0x0A, ZEROSIZEFILE = 0x0B, NOWRITE = 0x0C, SHUTDOWN = 0x0D, AGAIN = 0x0E, HANDSHAKEREQUIRED = 0x0F, TIMEOUT = 0x10, BINDFAIL = 0x11 } |

## Functions

|                                                                                                         | Name                                                                                                                                                                                                                                          |
| ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| std::string                                                                                             | [**NameOf**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum#function-nameof)(const [Type](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum#enum-type) & in\_enum) |
| [Type](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum#enum-type) | [**Enum**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum#function-enum)(const std::string & in\_string)                                                                                               |
| bool                                                                                                    | [**IsValid**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum#function-isvalid)(const int & in\_value)                                                                                                  |

## Types Documentation

### enum Type

| Enumerator        | Value | Description                            |
| ----------------- | ----- | -------------------------------------- |
| OK                | 0x00  | call completed successfully            |
| FAIL              | 0x01  | call completed unsuccessfully          |
| BADPARAM          | 0x02  | issue with provided parameter          |
| MISCONFIGURED     | 0x03  | a configuration blocked the call       |
| INCOMPLETE        | 0x04  | the process started but did not finish |
| DENIED            | 0x05  | operation not allowed                  |
| BADINIT           | 0x06  | call on non-initialized object         |
| PROTOCOL          | 0x07  | guardian protocol error                |
| OUTOFMEMORY       | 0x08  | not enough memory                      |
| VERIFYFAIL        | 0x09  | signature verification failed          |
| FILENOTFOUND      | 0x0A  | could not read all necessary files     |
| ZEROSIZEFILE      | 0x0B  | provided file is zero length           |
| NOWRITE           | 0x0C  | could not write file                   |
| SHUTDOWN          | 0x0D  | the object is shutdown                 |
| AGAIN             | 0x0E  | non-blocking call, try again           |
| HANDSHAKEREQUIRED | 0x0F  | complete handshake before retry        |
| TIMEOUT           | 0x10  | the process timed out                  |
| BINDFAIL          | 0x11  | could not bind to socket or handle     |

## Functions Documentation

### function NameOf

```cpp
std::string NameOf(
    const Type & in_enum
)
```

### function Enum

```cpp
Type Enum(
    const std::string & in_string
)
```

### function IsValid

```cpp
bool IsValid(
    const int & in_value
)
```


# medcrypt::guardian::LogLevelEnum

## Types

|      | Name                                                                                                                                                    |
| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| enum | [**Type**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-loglevelenum#enum-type) { Critical = 0, Error, Warn, Info, Debug, Trace } |

## Functions

|                                                                                                   | Name                                                                                                                                                                                                                              |
| ------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| std::string                                                                                       | [**NameOf**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-loglevelenum#function-nameof)(const [Type](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-loglevelenum#enum-type) & in\_enum) |
| [Type](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-loglevelenum#enum-type) | [**Enum**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-loglevelenum#function-enum)(const std::string & in\_string)                                                                                         |
| bool                                                                                              | [**IsValid**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-loglevelenum#function-isvalid)(const int & in\_value)                                                                                            |

## Types Documentation

### enum Type

| Enumerator | Value | Description                              |
| ---------- | ----- | ---------------------------------------- |
| Critical   | 0     | probable crash                           |
| Error      |       | could not complete requested action      |
| Warn       |       | action completed with unexpected outcome |
| Info       |       | relevant information                     |
| Debug      |       | debug output, debug builds only          |
| Trace      |       | trace output, internal builds only       |

## Functions Documentation

### function NameOf

```cpp
std::string NameOf(
    const Type & in_enum
)
```

### function Enum

```cpp
Type Enum(
    const std::string & in_string
)
```

### function IsValid

```cpp
bool IsValid(
    const int & in_value
)
```


# medcrypt::guardian::utilities

## Classes

|        | Name                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| struct | <p><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-InitializeFiles.md"><strong>medcrypt::guardian::utilities::InitializeFiles</strong></a> <br>Storage for initialization files used by <a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-Guardian.md#function-initialize">Guardian::Initialize</a>.</p>                                     |
| struct | <p><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-ProvisionFiles.md"><strong>medcrypt::guardian::utilities::ProvisionFiles</strong></a> <br>Storage for generating provision request files in <a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-Guardian.md#function-generateprovisionrequest">Guardian::GenerateProvisionRequest</a>.</p>  |
| struct | <p><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-ProvisionOnlineFiles.md"><strong>medcrypt::guardian::utilities::ProvisionOnlineFiles</strong></a> <br>Storage for online provisioning files in <a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-Guardian.md#function-startprovisioningonline">Guardian::StartProvisioningOnline</a>.</p> |

## Functions

|      | Name                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| bool | <p><a href="/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities#function-getinitializefilesfrompath"><strong>GetInitializeFilesFromPath</strong></a>(const std::string & in\_filespath, const bool & in\_use\_provision\_files, <a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-InitializeFiles.md">InitializeFiles</a> \* io\_files, const std::string & in\_prefix ="") <br>Populate file buffers required by <a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-Guardian.md#function-initialize">Guardian::Initialize</a> from path.</p>                         |
| void | <p><a href="/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities#function-deleteinitializefilebuffers"><strong>DeleteInitializeFileBuffers</strong></a>(<a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-InitializeFiles.md">InitializeFiles</a> \* io\_files) <br>Delete dynamic memroy in created by <a href="/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities#function-getinitializefilesfrompath">GetInitializeFilesFromPath()</a></p>                                                                                                                                                                    |
| bool | <p><a href="/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities#function-getprovisionfilesfrompath"><strong>GetProvisionFilesFromPath</strong></a>(const std::string & in\_filespath, const bool & in\_use\_provision\_files, <a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-ProvisionFiles.md">ProvisionFiles</a> \* io\_files, const std::string & in\_prefix ="") <br>Populate file buffers required by <a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-Guardian.md#function-generateprovisionrequest">Guardian::GenerateProvisionRequest</a> from path.</p> |
| void | <p><a href="/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities#function-deleteprovisionfilebuffers"><strong>DeleteProvisionFileBuffers</strong></a>(<a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-ProvisionFiles.md">ProvisionFiles</a> \* io\_files) <br>Delete dynamic memroy in created by <a href="/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities#function-getprovisionfilesfrompath">GetProvisionFilesFromPath()</a></p>                                                                                                                                                                          |

## Attributes

|            | Name                                                                                                                                     |
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| const char | [**kRequestExtension**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities#variable-krequestextension)         |
| const char | [**kProfileExtension**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities#variable-kprofileextension)         |
| const char | [**kRunProfileExtension**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities#variable-krunprofileextension)   |
| const char | [**kIdentityExtension**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities#variable-kidentityextension)       |
| const char | [**kRunIdentityExtension**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities#variable-krunidentityextension) |
| const char | [**kTrustExtension**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities#variable-ktrustextension)             |
| const char | [**kRevocationExtension**](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities#variable-krevocationextension)   |

## Functions Documentation

### function GetInitializeFilesFromPath

```cpp
static inline bool GetInitializeFilesFromPath(
    const std::string & in_filespath,
    const bool & in_use_provision_files,
    InitializeFiles * io_files,
    const std::string & in_prefix =""
)
```

Populate file buffers required by [Guardian::Initialize](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-Guardian.md#function-initialize) from path.

**Parameters**:

* **in\_filespath** absolute or working directory relative path to profile files&#x20;
* **in\_use\_provision\_files** used to return provisioning profiles for initializing to run online provisioning&#x20;
* **io\_files** file structure to populate&#x20;
* **in\_prefix** prefix that each found file is required to have, allows multiple profile sets in the same folder separated by file prefix

**Returns**:

* **true** io\_files populated successfully&#x20;
* **false** io\_files not populated&#x20;

**Return**: bool

Searches for files in in\_filepath with prefix in\_prefix. Sorts alphanumerically after applying prefix and uses the first result.

Note: This function creates memory in [InitializeFiles](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-InitializeFiles.md) char\* buffers using new\[], its paired [DeleteInitializeFileBuffers()](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities#function-deleteinitializefilebuffers) function will delete the created dynamic memory.

### function DeleteInitializeFileBuffers

```cpp
static inline void DeleteInitializeFileBuffers(
    InitializeFiles * io_files
)
```

Delete dynamic memroy in created by [GetInitializeFilesFromPath()](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities#function-getinitializefilesfrompath)

**Parameters**:

* **io\_files** file structure to clean up

**Return**: none

Calls delete\[] on all [InitializeFiles](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-InitializeFiles.md) char\* buffers.

### function GetProvisionFilesFromPath

```cpp
static inline bool GetProvisionFilesFromPath(
    const std::string & in_filespath,
    const bool & in_use_provision_files,
    ProvisionFiles * io_files,
    const std::string & in_prefix =""
)
```

Populate file buffers required by [Guardian::GenerateProvisionRequest](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-Guardian.md#function-generateprovisionrequest) from path.

**Parameters**:

* **in\_filespath** absolute or working directory relative path to profile files&#x20;
* **in\_use\_provision\_files** used to return provisioning profiles, usually should be true&#x20;
* **io\_files** file structure to populate&#x20;
* **in\_prefix** prefix that each found file is required to have, allows multiple profile sets in the same folder separated by file prefix

**Returns**:

* **true** io\_files populated successfully&#x20;
* **false** io\_files not populated&#x20;

**Return**: bool

Searches for files in in\_filepath with prefix in\_prefix. Sorts alphanumerically after applying prefix and uses the first result.

Note: This function creates memory in [ProvisionFiles](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-ProvisionFiles.md) char\* buffers using new\[], its paired [DeleteProvisionFileBuffers()](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities#function-deleteprovisionfilebuffers) function will delete the created dynamic memory.

Note: This function does not create memory for outputs [ProvisionFiles::ProvisionRequest](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-ProvisionFiles.md#variable-provisionrequest) or [ProvisionFiles::GeneratedPrivateIdentity](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-ProvisionFiles.md#variable-generatedprivateidentity)

### function DeleteProvisionFileBuffers

```cpp
static inline void DeleteProvisionFileBuffers(
    ProvisionFiles * io_files
)
```

Delete dynamic memroy in created by [GetProvisionFilesFromPath()](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities#function-getprovisionfilesfrompath)

**Parameters**:

* **io\_files** file structure to clean up

**Return**: none

Calls delete\[] on all [ProvisionFiles](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-ProvisionFiles.md) char\* buffers except for outputs [ProvisionFiles::ProvisionRequest](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-ProvisionFiles.md#variable-provisionrequest) and [ProvisionFiles::GeneratedPrivateIdentity](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-ProvisionFiles.md#variable-generatedprivateidentity)

## Attributes Documentation

### variable kRequestExtension

```cpp
static const char kRequestExtension = ".mcpr";
```

Provision request file extension

### variable kProfileExtension

```cpp
static const char kProfileExtension = ".mcpp";
```

Certified provisioning profile file extension

### variable kRunProfileExtension

```cpp
static const char kRunProfileExtension = ".mcp";
```

Certified profile file extension

### variable kIdentityExtension

```cpp
static const char kIdentityExtension = ".mcpip";
```

Provisioning private identity file extension

### variable kRunIdentityExtension

```cpp
static const char kRunIdentityExtension = ".mcpi";
```

Private identity file extension

### variable kTrustExtension

```cpp
static const char kTrustExtension = ".mcts";
```

Trust store file extension

### variable kRevocationExtension

```cpp
static const char kRevocationExtension = ".mccrl";
```

Certificate revocation list file extension


# Classes

The [medcrypt namespace ](/api-reference/api-reference/namespaces/namespacemedcrypt)contains the [guardian namespace](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian), which includes the following classes, structures, and enumerations:

## **Core classes**

* [Guardian](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian) class:&#x20;
  * **Description:** Root of Guardian system.&#x20;
  * **Location:** medcrypt::guardian::Guardian
* [AuthenticationManager](/api-reference/api-reference/classes/classmedcrypt-guardian-authenticationmanager) class:&#x20;
  * **Description:** Container for authentication restrictions.&#x20;
  * **Location:** medcrypt::guardian::AuthenticationManager
* [ChannelGuard](/api-reference/api-reference/classes/classmedcrypt-guardian-channelguard) class:&#x20;
  * **Description:** Name channel within a [Session](/api-reference/api-reference/classes/classmedcrypt-guardian-session).&#x20;
  * **Location:** medcrypt::guardian::ChannelGuard
* [SecureOperation](/api-reference/api-reference/classes/classmedcrypt-guardian-secureoperation) class:&#x20;
  * **Description:** Named standalone operation.&#x20;
  * **Location:** medcrypt::guardian::SecureOperation
* [Service](/api-reference/api-reference/classes/classmedcrypt-guardian-service) class:&#x20;
  * **Description:** Named group of connection and channel configurations.
  * **Location:** medcrypt::guardian::Service
* [Session](/api-reference/api-reference/classes/classmedcrypt-guardian-session) class:&#x20;
  * **Description:** Individual connection within a [Service](/api-reference/api-reference/classes/classmedcrypt-guardian-service).
  * **Location:** medcrypt::guardian::Session
* [Task](/api-reference/api-reference/classes/classmedcrypt-guardian-task) class:&#x20;
  * **Description:** Multithreading container.&#x20;
  * **Location:** medcrypt::guardian::Task
* [TransportInterface](/api-reference/api-reference/classes/classmedcrypt-guardian-transportinterface) class:&#x20;
  * **Description:** [ConfigureTransport()](/api-reference/api-reference/classes/classmedcrypt-guardian-service#function-configuretransport) required interface.&#x20;
  * **Location:** medcrypt::guardian::TransportInterface

## **Data structures**

* [AuthenticationDomain](/api-reference/api-reference/classes/structmedcrypt-guardian-authenticationdomain) struct:&#x20;
  * **Description:** Authentication restriction container. Restrictions for use by an authentication agent.&#x20;
  * **Location:** medcrypt::guardian::AuthenticationDomain
* [InitializeOptions](/api-reference/api-reference/classes/structmedcrypt-guardian-initializeoptions) struct:&#x20;
  * **Description:** Options used by [Initialize()](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-2-run-initialize) during setup.&#x20;
  * **Location:** medcrypt::guardian::InitializeOptions
* [ProvisioningOptions](/api-reference/api-reference/classes/structmedcrypt-guardian-provisioningoptions) struct:&#x20;
  * **Description:** Options used by [StartProvisioningOnline()](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-4-startprovisioningonline).&#x20;
  * **Location:** medcrypt::guardian::ProvisioningOptions

### Utility namespace & structures

The [guardian namespace](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian) also includes the [utilities](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-utilities) namespace, which includes the following structures:

* [InitializeFiles](/api-reference/api-reference/classes/structmedcrypt-guardian-utilities-initializefiles) struct:&#x20;
  * **Description:** Storage for initialization files used by [Initialize()](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-2-run-initialize).&#x20;
  * **Location:** medcrypt::guardian::utilities::InitializeFiles
* [ProvisionFiles](/api-reference/api-reference/classes/structmedcrypt-guardian-utilities-provisionfiles) struct:&#x20;
  * **Description:** Storage for generating provision request files in [GenerateProvisionRequest()](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-3-run-generateprovisionrequest).&#x20;
  * **Location:** medcrypt::guardian::utilities::ProvisionFiles
* [ProvisionOnlineFiles](/api-reference/api-reference/classes/structmedcrypt-guardian-utilities-provisiononlinefiles) struct:
  * **Description:** Storage for online provisioning files in [StartProvisioningOnline()](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-4-startprovisioningonline).
  * **Location:** medcrypt::guardian::utilities::ProvisionOnlineFiles

## **Other namespaces**

* [AuthenticationAllowDenyEnum](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-authenticationallowdenyenum)  namespace:&#x20;
  * **Description:** Determines whether a specified list is in an allow or deny list.
  * **Location:** medcrypt::guardian::AuthenticationAllowDenyEnum
* [GuardianStatusEnum](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum) namespace:
  * **Description:** Status codes returned by Guardian functions.
  * **Location:** medcrypt::guardian::GuardianStatusEnum
* [LogLevelEnum](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-loglevelenum) namespace:
  * **Description:** Log levels returned by Guardian functions.&#x20;
  * **Location:** medcrypt::guardian::LogLevelEnum


# medcrypt::guardian::AuthenticationDomain

Authentication restriction container. Restrictions for use by an authentication agent.

`#include <AuthenticationManager.h>`

## Public Attributes

|                                                                                                                                                                                                    | Name                                                                                                                                                                                   |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| std::string                                                                                                                                                                                        | [**service\_name**](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-AuthenticationDomain.md#variable-service_name)      |
| std::string                                                                                                                                                                                        | [**domain**](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-AuthenticationDomain.md#variable-domain)                   |
| [AuthenticationAllowDenyEnum::Type](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian-AuthenticationAllowDenyEnum.md#enum-type) | [**ip\_allow\_deny**](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-AuthenticationDomain.md#variable-ip_allow_deny)   |
| std::list< std::string >                                                                                                                                                                           | [**ip\_addresses**](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-AuthenticationDomain.md#variable-ip_addresses)      |
| [AuthenticationAllowDenyEnum::Type](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian-AuthenticationAllowDenyEnum.md#enum-type) | [**key\_allow\_deny**](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-AuthenticationDomain.md#variable-key_allow_deny) |
| std::list< std::vector< uint8\_t > >                                                                                                                                                               | [**public\_keys**](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-AuthenticationDomain.md#variable-public_keys)        |

## Public Attributes Documentation

### variable service\_name

```cpp
std::string service_name;
```

the name of the service the contained

### variable domain

```cpp
std::string domain;
```

transport specific authentication domain, usually string representation of a port

### variable ip\_allow\_deny

```cpp
AuthenticationAllowDenyEnum::Type ip_allow_deny;
```

are the addresses in the following list allowed or denied

### variable ip\_addresses

```cpp
std::list< std::string > ip_addresses;
```

string representations of IP addresses

### variable key\_allow\_deny

```cpp
AuthenticationAllowDenyEnum::Type key_allow_deny;
```

are the keys in the following list allowed or denied

### variable public\_keys

```cpp
std::list< std::vector< uint8_t > > public_keys;
```

vectors of public key bytes

## Debugging and logging

Guardian does not create log files. Instead, logging is controlled by the application:

* Guardian logs to `stdout` and `stderr`, which appear in the terminal/CLI of the running application during execution. Look for specific error codes or connection failures in the output.
* **Custom logging:** Use `SetLoggingCallback` to redirect log messages to a callback function, stopping terminal output and allowing custom log handling
* **Log control:** Applications can control log level and verbosity.
* **Guardian Cloud UI**: Check the Guardian Cloud interface for additional error details and provisioning status.


# medcrypt::guardian::AuthenticationManager

Container for authentication restrictions.

`#include <AuthenticationManager.h>`

## Public functions

<table data-header-hidden><thead><tr><th>Name</th><th>Description</th><th data-hidden></th></tr></thead><tbody><tr><td>Name</td><td></td><td></td></tr><tr><td><a href="/pages/-Mgn-Md2NyPOXkTvYNSE#function-~authenticationmanager"><strong>~AuthenticationManager</strong></a>() </td><td>This is the destructor.</td><td></td></tr><tr><td><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-authenticationmanager#function-getrestrictions"><strong>GetRestrictions</strong></a>(std::list&#x3C; <a href="/api-reference/api-reference/classes/structmedcrypt-guardian-authenticationdomain">AuthenticationDomain</a> > * out_restrictions_by_domain) </td><td>This gets all restrictions.</td><td><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status">Status</a></td></tr><tr><td><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-authenticationmanager#function-getrestrictionbyservice"><strong>GetRestrictionByService</strong></a>(const char <em>in_service_name,</em> <a href="/api-reference/api-reference/classes/structmedcrypt-guardian-authenticationdomain"><em>AuthenticationDomain</em></a>  out_restriction) </td><td>This gets all restrictions by service.</td><td><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status">Status</a></td></tr></tbody></table>

### function \~AuthenticationManager

```cpp
~AuthenticationManager()
```

The destructor.

**Parameters**:

* **none**&#x20;

**Return**: none

The destructor does no work.

### function GetRestrictions

```cpp
Status GetRestrictions(
    std::list< AuthenticationDomain > * out_restrictions_by_domain
)
```

Get all restrictions.

**Parameters**:

* **out\_restrictions\_by\_domain** list of domains and their restrictions,

**Returns**:

* **OK** out\_restrictions\_by\_domain is populated with restrictions&#x20;
* **FAIL** general failure, out\_restrictions\_by\_domain is unmodified&#x20;
* **BADPARAM** out\_restrictions\_by\_domain is nullptr&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Returns a list of all AuthenticationRestrictions in the system.

### function GetRestrictionByService

```cpp
Status GetRestrictionByService(
    const char * in_service_name,
    AuthenticationDomain * out_restriction
)
```

Get restrictions by service.

**Parameters**:

* **in\_service\_name** null terminated string of service name&#x20;
* **out\_restriction** restriction set for in\_service\_name

**Returns**:

* **OK** out\_restriction is populated with restrictions for in\_service\_name&#x20;
* **FAIL** general failure, out\_restriction is unmodified&#x20;
* **BADPARAM** in\_service\_name is nullptr or empty, or out\_restriction is nullptr&#x20;
* **MISCONFIGURED** in\_service\_name cannot be found or is not configured to share restrictions&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Returns a single AuthenticationRestriction for the specified service name

## Debugging and logging

Guardian does not create log files. Instead, logging is controlled by the application:

* Guardian logs to `stdout` and `stderr`, which appear in the terminal/CLI of the running application during execution. Look for specific error codes or connection failures in the output.
* **Custom logging:** Use `SetLoggingCallback` to redirect log messages to a callback function, stopping terminal output and allowing custom log handling
* **Log control:** Applications can control log level and verbosity.
* **Guardian Cloud UI**: Check the Guardian Cloud interface for additional error details and provisioning status.


# medcrypt::guardian::Guardian

## Overview

The `Guardian` class is the main interface for the Guardian security platform. It provides device provisioning, secure communication, and cryptographic operations for medical devices. It handles the following throughout the device lifecycle:

* Device identity establishment&#x20;
* Secure connections&#x20;
* Certificate management

**Include**

```cpp
#include <Guardian.h>
```

### Device provisioning functions

* [Guardian](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#function-guardian) : The constructor does no work besides initializing member variables.
* [Initialize](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#function-initialize): Uses the provided profile, identity, and trust files to initialize the Guardian system.
* [GenerateProvisionRequest](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#function-generateprovisionrequest): This is the first device provisioning step for the provisioning process.
* [StartProvisioningOnline](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#function-startprovisioningonline): Start the online device provisioning process.
* [IsProvisioningRunning](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#function-isprovisioningrunning): Check if provisioning process is active.
* [GetProvisionedProfile](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#function-getprovisionedprofile): Extract provisioned certified profile for device after successful device provisioning.

### Certificate management functions

* [GetCertificateManager:](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#function-getcertificatemanager) Retrieve the running certificate manager.
* [GetProvisionedRevocationList](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#function-getprovisionedrevocationlist): Retrieve certificate revocation list and populate into buffer.&#x20;

### **Security operations functions**

* [FindSecureOperation](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#function-findsecureoperation):  Perform a lookup to get secure operation handler for signing/verification

### **Service management functions**

* [FindService](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#function-findservice): Perform a service name lookup to locate a configured service.
* [CreateTask](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#function-createtask): Create a task for service, session, or channel operations that separates the provided object and all children from [Run](#function-run).

### **System management functions**

* [GetAuthenticationManager](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#function-getauthenticationmanager): Retrieve the running authentication manager.
* [GetTelemetryManager](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#function-gettelemetrymanager): Retrieve the running telemetry manager.
* [\~Guardian](https://docs.medcrypt.com/api-reference/api-reference/classes/pages/-MD0rw0qMat4rv0A8KkC#function-~guardian) : The destructor attempts a graceful shutdown of Guardian.
* [Shutdown](#function-shutdown): Clean shutdown of Guardian

## Device setup and provisioning workflow

### Steps overview

#### [Prerequisites: Create Guardian instance](#guardian)

**Function:** `Guardian()`

* Creates new Guardian instance
* First step before any other operations
* Initializes member variables and puts system in startup state

#### [Step 1: Device setup](#function-initialize)

**Function:** `Initialize()`

* Must be called first after creating Guardian instance
* Sets up Guardian with initial configuration
* Required before any provisioning operations

#### [Step 2: Generate provisioning request](#generateprovisionrequest)

**Function:** `GenerateProvisionRequest()`

* Creates provisioning request (.mcpr) and private identity (.mcpi) files
* Uses provisioning package to generate device keys
* Must be called once before any other provisioning actions

#### [Step 3: Submit and process request](#function-startprovisioningonline)

**Function:** `StartProvisioningOnline()`

* Initiates online provisioning state machine
* Submits provisioning request to Guardian Cloud
* Begins automated processing workflow

#### [Step 4: Monitor provisioning and retrieve device's certified profile](#function-getprovisionedprofile)

**Functions:** `Run()`, `IsProvisioningRunning()`, `GetProvisionedProfile()`

* `Run()` : Executes background provisioning tasks
* `IsProvisioningRunning()` : Checks if provisioning process is still running
* `GetProvisionedProfile()` - Retrieve completed certified profile for device

### Step 1: Run Guardian()

* **Description:**&#x20;
  * Creates a new Guardian instance.&#x20;
  * This is the first step before initializing Guardian with device credentials.&#x20;
  * This constructor only initializes member variables.
* **Dependencies:** None - this is the first function to call
* **Parameters:** None - default constructor takes no parameters
* **Returns:** Nothing since it is a constructor.
* **Action:** Gets Guardian instance into startup state, ready for initialization (`m_p_guardian`).

**Syntax**

```cpp
Guardian()
```

### Step 2: Run Initialize()

* **Description:** Initializes Guardian with device credentials and configuration files. Uses the provided profile, identity, and trust files to initialize the guardian system.&#x20;
* **Dependencies:**
  * Must be called after [creating a Guardian instance](#guardian)  (`Guardian()` constructor).
  * Must be called before any other Guardian operations
* **Parameters:**&#x20;
  * `in_files`: Device credentials and configuration files
  * `in_component_handle`: This is the unique component identifier used for provisioning.&#x20;
    * **Type:** `const char*`
  * `in_hardware_identifier`: This is the unique hardware identifier.&#x20;
    * **Character limitations:** 36 (37 with null terminator)&#x20;
    * **Type:** `const char*`
  * `in_options`: Additional initialization configuration options
* **Returns:** Status code indicating success or failure.&#x20;
  * **Success code:** `OK`**.** Guardian system was successfully initialized.
  * **Error codes:**
    * `FAIL`:  General failure. Guardian did not initialize successfully.  Check the log file for more information.
    * `BADPARAM`: One of the inputs is null or empty.&#x20;
    * `FILENOTFOUND`: A required input file is unavailable.
    * `OUTOFMEMORY` **:** Not enough memory to initialize Guardian.&#x20;
  * **See also:** [All status codes](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum)&#x20;
* **Action:** Sets up Guardian with device identity and prepares it for secure operations.

**Syntax**

```cpp
Status Initialize(
    const utilities::InitializeFiles & in_files,
    const char * in_component_handle,
    const char * in_hardware_identifier,
    const InitializeOptions & in_options
)
```

### Step 3: Run GenerateProvisionRequest()

* **Description:** Creates a provisioning request for device identity establishment.&#x20;
  * This is the first provisioning step for the provisioning process.&#x20;
  * This is the only step in the offline provisioning process.&#x20;
  * Uses input files to generate a provisioning request and private identity
* **Dependencies:**
  * Must be called after `Initialize()`
  * Must be called once before any other provisioning or re-provisioning actions occur.&#x20;
  * Required before `StartProvisioningOnline()`
* **Parameters:**&#x20;
  * &#x20;`io_files` : Provisioning files structure.\
    &#x20;`in_provisioning_component_handle` : This is the unique component identifier used for provisioning.&#x20;
    * **Type:** `const char*`
  * &#x20;`in_provisioning_system` : This is the unique system name identifier which is sent to Guardian Cloud.&#x20;
    * **Character limitations:** 36 (37 with null terminator)&#x20;
    * **Type:** `const char*`
  * &#x20;`in_hardware_identifier`  - This is the unique hardware identifier.&#x20;
    * **Character limitations:** 36 (37 with null terminator)&#x20;
    * **Type:** `const char*`
* **Returns:** Status code indicating success or failure.&#x20;
  * **Success code:** `OK`**.** Provisioning request was successfully created
  * **Error codes:**
    * `FAIL`:  General failure. Check the log file for more information.&#x20;
    * `BADPARAM`: One of the inputs is null or empty&#x20;
    * `FILENOTFOUND`: A required input file is unavailable&#x20;
    * `NOWRITE`: A required output file could not be written&#x20;
    * `OUTOFMEMORY` : Not enough memory to provision&#x20;
  * **See also:** [All status codes](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum)&#x20;
* **Actions:**&#x20;
  * Generates device keys and creates provisioning request.&#x20;
  * Will create a private identity ( `PrivateIdentity` ) for the device, as well as the device's provisioning request ( `ProvisionRequest` ).&#x20;
    * The `PrivateIdentity` includes the generated device keys. This is the **.mcpi** file.
    * The `ProvisionRequest` can be manually uploaded to Guardian Cloud or sent using available online methods in the profile. This is the **.mcpr** file.

**Syntax**

```cpp
Status GenerateProvisionRequest(
    utilities::ProvisionFiles & io_files,
    const char * in_provisioning_component_handle,
    const char * in_provisioning_system,
    const char * in_hardware_identifier
)
```

### Step 4: StartProvisioningOnline()

* **Description:** Starts the online provisioning process to submit a provisioning request to Guardian Cloud.&#x20;
* **Dependencies:** Must be run after [GenerateProvisionRequest()](#generateprovisionrequest).
* **Parameters:**
  * `in_files`: Files required for online provisioning
  * `in_options`: Additional optional provisioning configuration options, including timeouts
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` : Online provisioning was successfully started
  * **Error codes:**
    * `FAIL` : General failure starting provisioning.  Check the log file for more information.
    * `BADPARAM` : One of the inputs is null or invalid
    * `FILENOTFOUND` : A required provisioning file is unavailable
  * **See also:** [All status codes](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum)&#x20;
* **Action:** Starts internal provisioning state machine and begins communication with Guardian Cloud

**Syntax**

```cpp
Status StartProvisioningOnline(
    const utilities::ProvisionOnlineFiles & in_files,
    const ProvisioningOptions & in_options
)
```

### Step 5: Monitor provisioning and retrieve device's certified profile

**Process overview:**

1. Call [`Run()`](#run) repeatedly to process provisioning tasks
2. Call [`IsProvisioningRunning()`](#isprovisioningrunning) to check if provisioning is complete
3. When `IsProvisioningRunning()` returns false, call [`GetProvisionedProfile()`](#function-getprovisionedprofile) to retrieve the certified profile

#### Run()

* **Description:**&#x20;
  * Executes Guardian background tasks including provisioning state machine processing.&#x20;
  * Includes provisioning, telemetry, handshakes, authentication, services, sessions, and channels that have not been placed or had a parent placed on another thread by [CreateTask](#function-createtask). This should be called by the program/thread's main loop.
  * Must be called regularly and repeatedly during online provisioning.&#x20;
  * Use [IsProvisioningRunning()](#function-isprovisioningrunning) to check when provisioning is complete and stop calling Run().&#x20;
* **Parameters:** No parameters
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` - Background tasks executed successfully
  * **Error codes:**
    * `FAIL` - General failure in background processing.  Check the log file for more information.
    * `SHUTDOWN` : Guardian is in a shutdown state and must be reinitialized before calling run again.&#x20;
  * **See also:** [All status codes](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum)&#x20;
* **Action:** Processes internal state machines and handles communication with Guardian Cloud

#### IsProvisioningRunning()

* **Description:** Checks whether the provisioning process is still active.&#x20;
* **Dependencies:**
  * Must be called after `StartProvisioningOnline()`
  * Used to determine when to stop calling [Run()](#run) and attempt to retrieve the provisioned profile.
* **Parameters:** None - this function takes no parameters
* **Returns:** Boolean value indicating provisioning status
  * `true` - Provisioning is still in progress. Continue calling [Run()](#run)
  * `false` - Provisioning has completed (successfully or failed). You should now call [GetProvisionedProfile()](#function-getprovisionedprofile).
  * Before the online provisioning process has started, will return `false`.
  * After online provisioning has either succeeded or failed, will again return `false`.
* **Action:** Indicates whether provisioning process is still active

**Syntax**

```cpp
bool IsProvisioningRunning()
```

#### GetProvisionedProfile()

* **Description:**&#x20;
  * Extracts the provisioned profile after successful online provisioning.&#x20;
* **Dependencies:**
  * Must be called only after [IsProvisioningRunning()](#isprovisioningrunning) returns `false`.
  * Requires successful completion of `StartProvisioningOnline()` and `Run()` loop
* **Parameters:**
  * `out_profile`: Buffer that will receive the provisioned profile.
    * Type: `char`
  * `io_size`:&#x20;
    * Provide size of buffer ( `out_profile` ) on input. After successful provisioning, `out_profile` sets to actual size of profile.
    * Type: `size_t`&#x20;
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` : Provisioned profile successfully retrieved.&#x20;
    * Buffer contains a valid certified profile in  `out_profile` of size `io_size`.&#x20;
  * **Error codes:**
    * `FAIL` : General failure. Check the log file for more information.
    * `INCOMPLETE` : Provisioning process did not complete, thus no profile is available.
    * `BADPARAM` - `out_profile` or `io_size` is null pointer (`nullptr`), or `io_size` is 0
    * `DENIED` - Online provisioning process is still running
    * `FILENOTFOUND` - Provisioning is complete but no provisioned profile is available
    * `BADPARAM` - Buffer or size parameter is invalid&#x20;
  * **See also:** [All status codes](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum)&#x20;
* **Action:** Copies completed provisioned profile to provided buffer.

**Syntax**

```cpp
Status GetProvisionedProfile(
    char * out_profile,
    size_t * io_size
)
```

## Certificate management functions

### GetCertificateManager()

* **Description:** Retrieves the certificate manager for handling device certificates. Provides access to certificate operations and lifecycle management.
* **Dependencies:**
  * Can optionally be called after `Initialize()`
* **Parameters:**
  * `out_certificate_manager`: Output pointer to receive the certificate manager instance
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` :&#x20;
    * Certificate manager successfully retrieved
    * The pointer in `out_certificate_manager` is valid&#x20;
  * **Error codes:**
    * `FAIL` : General failure. Check the log file for more information.
    * `BADPARAM` : `out_certificate_manager` is a null pointer and cannot be filled
    * `DENIED` : Guardian is not initialized
    * `MISCONFIGURED` : The loaded provisioned profile is not configured to allow certificate operations.
  * **See also:** [All status codes](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum)&#x20;
* **Action:**&#x20;
  * Use the retrieved certificate manager to import and export certificates.

**Syntax**

```cpp
Status GetCertificateManager(
    std::unique_ptr< CertificateManager > * out_certificate_manager
)
```

### GetProvisionedRevocationList()

* **Description:**&#x20;
  * Retrieves the certificate revocation list (CRL) for checking certificate validity.&#x20;
  * Used to identify revoked certificates that should no longer be trusted.
* **Dependencies:**
  * Can optionally be called after successful provisioning (after `GetProvisionedProfile` )
* **Parameters:**
  * `out_ccrl`: Buffer to receive the certificate revocation list
    * Type: `char*`
  * `io_size`: Size of buffer on input, actual size on output
    * Provide size of buffer ( `out_ccrl` ) on input. After successful provisioning, `out_ccrl` sets to actual size of CRL.
    * Type: `size_t`&#x20;
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK`&#x20;
    * &#x20;`out_ccrl` has a valid revocation list of size `io_size`
  * **Error codes:**
    * `FAIL` - General failure. Check the log file for more information.
    * `INCOMPLETE` - Provisioning process did not complete, no revocation list available
    * `BADPARAM` : `out_ccrl` or `io_size` is null pointer, or `io_size` is 0
    * `DENIED` - Online provisioning process is still running
    * `FILENOTFOUND` - Provisioning is complete but no revocation list is available
  * **See also:** [All status codes](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum)&#x20;
* **Action:** Copies certificate revocation list to provided buffer

**Syntax**

```cpp
Status GetProvisionedRevocationList(
    char * out_ccrl,
    size_t * io_size
)
```

## Security operations function

### FindSecureOperation()

* **Description:**&#x20;
  * Perform lookup for secure operation name.&#x20;
  * Get secure operation handler for signing and verification operations.
* **Dependencies:**
  * Can optionally be called after `Initialize()`
* **Parameters:**
  * `in_secureop_name`: Secure operation name, terminated by null.
    * **Type**: `const char*`
  * `out_secureop`: Pointer to `unique_ptr` storage for located secure operation
* **Returns:** Status code indicating success or failure.
* **Success code:** `OK` : The pointer in `out_secureop` is valid
* **Error codes:**
  * `FAIL` : Could not find the operation specified by `in_secureop_name`
  * `BADPARAM` : `out_secureop` is null pointer and cannot be filled
  * `DENIED` : Guardian is not initialized
* **See also:** [All status codes](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum)&#x20;
* **Action:**&#x20;
  * Sets `out_secureop` to the located operation
  * Will not modify `out_secureop` if the operation `in_secureop_name` is not located

**Syntax**

```cpp
Status FindSecureOperation(
    const char * in_secureop_name,
    std::unique_ptr< SecureOperation > * out_secureop
)
```

## Service management functions

### FindService()

* **Description:**
  * Performs lookup for service name to locate a configured service.
* **Dependencies:**
  * Must be called after `Initialize()`
* **Parameters:**
  * `in_service_name`: Service name, terminated by null
    * **Type:** `const char*`
  * `out_service`: Pointer to unique\_ptr storage for found service
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` : The pointer in `out_service` is valid
  * **Error codes:**
    * `FAIL` : Could not find the service specified by `in_service_name`
    * `BADPARAM` : `out_service` is null pointer and cannot be filled
    * `DENIED` : Guardian is not initialized
  * **See also:** [All status codes](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum)&#x20;
* **Action:**&#x20;
  * Sets `out_service` to the located service&#x20;
  * Will not modify `out_service` if the service in `in_service_name` is not located
  * or leaves unmodified if the service is not found

**Syntax**

```cpp
Status FindService(
    const char * in_service_name,
    std::unique_ptr< Service > * out_service
)
```

### **CreateTask() - Service variant**

* **Description:**
  * Create a task for service operations that separates the provided object and all children from Run.
  * Allows for threading of separate objects by removing them from the main Guardian Run loop.
* **Dependencies:**
  * Must be called after `Initialize()`
  * Service object must be valid
* **Parameters:**
  * `io_service`: Service component to place on a thread, will be consumed on success, unmodified on failure
  * `out_task`: Pointer to unique\_ptr storage for the task
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` : out\_task has a valid task
  * **Error codes:**
    * `FAIL` : General failure. Check the log file for more information.
    * `BADPARAM` : io\_service or out\_task is null pointer
    * `DENIED` : Specified service is already in a task
  * **See also:** [All status codes](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum)&#x20;
* **Action:** A component placed on a Task along with all children will not run when Guardian Run is called, allowing for threading of separate objects

**Syntax**

```cpp
Status CreateTask(
    std::unique_ptr< Service > * io_service,
    std::unique_ptr< Task > * out_task
)
```

### CreateTask() - Session variant

* **Description:**
  * Create a task for service operations that separates the provided object and all children from Run.
  * Allows for threading of separate objects by removing them from the main [Run](#run) loop.
* **Dependencies:**
  * Can optionally be called after `Initialize()`
  * Service object must be valid
* **Parameters:**
  * `io_service`: Service component to place on a thread. This will be consumed on success, but not modified if not successful.
  * `out_task`: Pointer to `unique_ptr` storage for the task
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` : `out_task` has a valid task
  * **Error codes:**
    * `FAIL` : General failure. Check the log file for more information.
    * `BADPARAM` : `io_service` or `out_task` is null pointer
    * `DENIED` : Specified service is already in a task
  * **See also:** [All status codes](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum)&#x20;
* **Action:**&#x20;
  * A component placed on a Task along with all children will not run when [Run](#run) is called, allowing for threading of separate objects.
  * To return an object to the main Run loop, destroy the unique\_ptr.

**Syntax**

```cpp
Status CreateTask(
    std::unique_ptr< Session > * io_session,
    std::unique_ptr< Task > * out_task
)
```

### CreateTask() - ChannelGuard Variant

* **Description:**
  * Create a task for channel operations that separates the provided object and all children from [Run](#run).
  * Allows for threading of separate objects by removing them from the main [Run](#run) loop.
* **Dependencies:**
  * Must be called after `Initialize()`
  * `ChannelGuard` object must be valid
* **Parameters:**
  * `io_channelguard`: `ChannelGuard` component to place on a thread
  * `out_task`: Pointer to `unique_ptr` storage for the task
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` : `out_task` has a valid task
  * **Error codes:**
    * `FAIL` : General failure. Check the log file for more information.
    * `BADPARAM` : `io_channelguard` or `out_task` is null pointer
    * `DENIED` : Specified `ChannelGuard` is already in a task and has not been returned
  * **See also:** [All status codes](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum)&#x20;
* **Action:**&#x20;
  * A component placed on a Task along with all children will not run when [Run](#run) is called, allowing for threading of separate objects.
  * To return an object to the main Run loop, destroy the unique\_ptr.

**Syntax**

```cpp
Status CreateTask(
    std::unique_ptr< ChannelGuard > * io_channelguard,
    std::unique_ptr< Task > * out_task
)
```

## **System management functions**

### GetAuthenticationManager()

* **Description:**
  * Retrieve the running authentication manager.
  * Provides access to authentication operations and allow/deny lists for user-managed connections.
* **Dependencies:**
  * Can optionally be called after `Initialize()`
* **Parameters:**
  * `out_authentication_manager`: Pointer to unique\_ptr storage for authentication manager
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` : The pointer in `out_authentication_manager` is valid
  * **Error codes:**
    * `FAIL` : General failure. Check the log file for more information.
    * `BADPARAM` : `out_authentication_manager` is null pointer and cannot be filled
    * `DENIED` : Guardian is not initialized
    * `MISCONFIGURED` : The loaded profile is not configured to allow external authentication operations
  * **See also:** [All status codes](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum)&#x20;
* **Action:** Use the retrieved authentication manager to get allow/deny lists for user managed connections

**Syntax**

```cpp
Status GetAuthenticationManager(
    std::unique_ptr< AuthenticationManager > * out_authentication_manager
)
```

Retrieve the running authentication manager.

### GetTelemetryManager()

* **Description:**
  * Retrieve the running telemetry manager.
  * Provides access to telemetry service interactions.
* **Dependencies:**
  * Can optionally be called after `Initialize()`
* **Parameters:**
  * `out_telemtry_manager`: Pointer to `unique_ptr` storage for telemetry manager
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` : The pointer in `out_telemtry_manager` is valid
  * **Error codes:**
    * `FAIL` : General failure. Check the log file for more information.
    * `BADPARAM` : `out_telemtry_manager` is null pointer and cannot be filled
    * `DENIED` : Guardian is not initialized or there is no telemetry manager running
    * `MISCONFIGURED` : The loaded profile is not configured for telemetry
  * **See also:** [All status codes](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum)&#x20;
* **Action:** Use the retrieved telemetry manager to interact with the telemetry service

**Syntax**

```cpp
Status GetTelemetryManager(
    std::unique_ptr< Telemetry > * out_telemtry_manager
)
```

### \~Guardian()

* **Description:** The destructor attempts a graceful shutdown of Guardian.
* **Dependencies:** None - destructor is automatically called when object goes out of scope or is explicitly deleted
* **Parameters:** None - destructor takes no parameters
* **Returns:** Nothing since it is a destructor.
* **Action:** The destructor will attempt to call [Shutdown](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#function-shutdown) for a graceful shutdown, then Guardian will destruct.

**Syntax**

```cpp
~Guardian()
```

### Shutdown()

* **Description:**
  * Attempts to stop all internal state machines, shutting down Guardian.
  * Includes provisioning, telemetry, handshakes, authentication, services, sessions, and channels, INCLUDING those that have been placed or had a parent placed on another thread by [CreateTask](#createtask-service-variant).
* **Dependencies:**
  * Can optionally be called after `Initialize()`
  * If there is data waiting to be sent it will return a failure code or require `in_force`
* **Parameters:**
  * `in_force`: Drop all queued send data and shut down. Default value is `false`.
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` : Guardian is shut down successfully
  * **Error codes:**
    * `FAIL` : General failure. Check the log file for more information.
    * `AGAIN` : One or more transports has queued data to send
  * **See also:** [All status codes](/api-reference/api-reference/namespaces/namespacemedcrypt-guardian-guardianstatusenum)&#x20;
* **Action:** Stops all internal state machines including provisioning, telemetry, handshakes, authentication, services, sessions, and channels.

**Syntax**

```cpp
Status Shutdown(
    const bool & in_force =false
)
```

## Debugging and logging

Guardian does not create log files. Instead, logging is controlled by the application:

* Guardian logs to `stdout` and `stderr`, which appear in the terminal/CLI of the running application during execution. Look for specific error codes or connection failures in the output.
* **Custom logging:** Use `SetLoggingCallback` to redirect log messages to a callback function, stopping terminal output and allowing custom log handling
* **Log control:** Applications can control log level and verbosity.
* **Guardian Cloud UI**: Check the Guardian Cloud interface for additional error details and provisioning status.


# medcrypt::guardian::InitializeOptions

## Overview

These are the initialization configuration options to [initialize Guardian](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-2-run-initialize).

**Include:**

```cpp
#include <InitializeOptions.h>
```

**Syntax:**

```cpp
struct medcrypt::guardian::InitializeOptions;
```

### Structure members

* **is\_mocked:** Mocked profile flag
* **log\_level:** Log level enumeration

### Member details

#### is\_mocked:

* **Description:** Mocked profile flag that determines whether the profile provided for initialization is a non-node locked 'mocked' testing profile.
* **Type:** `bool`
* **Default value:** `false`
* **Syntax:**

```cpp
bool is_mocked = false;
```

#### log\_level:

* **Description:** Log level enumeration. See LogLevelEnum.h for accepted levels.
* **Type:** `LogLevelEnum::Type`
* **Default value:** `LogLevelEnum::Warn`
* `Syntax:`

```cpp
LogLevelEnum::Type log_level = [LogLevelEnum::Warn](/Namespaces/namespacemedcrypt-guardian-LogLevelEnum.md#enumvalue-warn);
```

### Related classes

* [Guardian class](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#overview): Uses `InitializeFiles` in [Initialize()](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-2-run-initialize) function
* LogLevelEnum namespace: Contains log level values

## Debugging and logging

Guardian does not create log files. Instead, logging is controlled by the application:

* Guardian logs to `stdout` and `stderr`, which appear in the terminal/CLI of the running application during execution. Look for specific error codes or connection failures in the output.
* **Custom logging:** Use `SetLoggingCallback` to redirect log messages to a callback function, stopping terminal output and allowing custom log handling
* **Log control:** Applications can control log level and verbosity.
* **Guardian Cloud UI**: Check the Guardian Cloud interface for additional error details and provisioning status.


# medcrypt::guardian::ProvisioningOptions

Options used by [Guardian::StartProvisioningOnline](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/classmedcrypt-guardian-Guardian.md#function-startprovisioningonline).

`#include <GuardianProvisioningOptions.h>`

## Public Functions

|   | Name                                                                                                                                                                                               |
| - | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|   | [**\~ProvisioningOptions**](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-ProvisioningOptions.md#function-~provisioningoptions)() |

## Public Attributes

|                                      | Name                                                                                                                                                                                                                                                          |
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| std::chrono::system\_clock::duration | <p><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-ProvisioningOptions.md#variable-connection_timeout"><strong>connection\_timeout</strong></a> <br>Initial connection timeout.</p>   |
| std::chrono::system\_clock::duration | <p><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-ProvisioningOptions.md#variable-response_timeout"><strong>response\_timeout</strong></a> <br>Time to wait for server response.</p> |
| std::chrono::system\_clock::duration | <p><a href="https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-ProvisioningOptions.md#variable-packet_resend"><strong>packet\_resend</strong></a> <br>Server polling time.</p>                    |

## Public Functions Documentation

### function \~ProvisioningOptions

```cpp
~ProvisioningOptions()
```

## Public Attributes Documentation

### variable connection\_timeout

```cpp
std::chrono::system_clock::duration connection_timeout = std::chrono::seconds(10);
```

Initial connection timeout.

If the connection does not complete within connection\_timeout the online provisioning process will fail.

### variable response\_timeout

```cpp
std::chrono::system_clock::duration response_timeout = std::chrono::seconds(10);
```

Time to wait for server response.

If the server does not respond with any status within response\_timeout the online provisioning process will fail.

### variable packet\_resend

```cpp
std::chrono::system_clock::duration packet_resend = std::chrono::seconds(10);
```

Server polling time.

Once the server has responded with any non-failing status, do not send another polling request until packet\_resend has elapsed since the last request was sent.

Example: if packet\_resend is 10 seconds, and the server response occurs 5 seconds after the initial request was sent, the next request will be sent approximately 5 seconds later.

## Debugging and logging

Guardian does not create log files. Instead, logging is controlled by the application:

* Guardian logs to `stdout` and `stderr`, which appear in the terminal/CLI of the running application during execution. Look for specific error codes or connection failures in the output.
* **Custom logging:** Use `SetLoggingCallback` to redirect log messages to a callback function, stopping terminal output and allowing custom log handling
* **Log control:** Applications can control log level and verbosity.
* **Guardian Cloud UI**: Check the Guardian Cloud interface for additional error details and provisioning status.


# medcrypt::guardian::Service

## Overview

This is a named group of connection and channel configurations.

**Usage:** This class is used to manage network connections and communication channels in Guardian applications.

**Include:**

```cpp
#include <Service.h>
```

**Syntax:**

```cpp
struct medcrypt::guardian::utilities::ProvisionOnlineFiles;
```

### Public functions

* [\~Service](#service): This is the destructor.
* [IsReady](#isready): Checks whether service is ready for operation.&#x20;
* [IsFailed](#isfailed): Checks whether the service in a failed state.
* [Listen](#listen): Allows a managed server service to listen for new connections.
* [ConfigureTransport](#start): Secures the provided transport based on the loaded profile.
* [Shutdown](#shutdown): Stops all contained connections, blocking for any queued data to send or fail to send.
* [Start](/api-reference/api-reference/classes/classmedcrypt-guardian-service#function-start) (no override): Starts connection. This is blocking.
* [Start](#start-with-override) (with override): Starts connection using the provided override string. This is blocking.
* [AsyncStart](/api-reference/api-reference/classes/classmedcrypt-guardian-service#function-asyncstart): Starts connection. This is non-blocking.
* [AsyncStart](/api-reference/api-reference/classes/classmedcrypt-guardian-service#function-asyncstart): Starts connection using the provided override string. This is non-blocking.
* [ClientWaiting](/api-reference/api-reference/classes/classmedcrypt-guardian-service#function-clientwaiting): Checks whether a client is waiting to connect. This is non-blocking.

### Function details

#### \~Service()

* **Description:** The destructor will not affect the internal [Guardian](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian) representation of the [Service](/api-reference/api-reference/classes/classmedcrypt-guardian-service)..
* **Dependencies:** None - destructor is called automatically
* **Parameters:** None - destructor takes no parameters
* **Returns:** Nothing since it is a destructor.
* **Action:** Cleans up service resources without affecting Guardian's internal representation.
* **Syntax:**

```cpp
~Service()
```

#### IsReady()

* **Description:** Check if the service is ready for operation.
* **Dependencies:** Must be called after service is created
* **Parameters:** None
* **Returns:** Boolean value indicating service readiness
  * `true` - Service is ready for its configured operations
  * `false` - Service is not ready or is a server service that is not listening
* **Action:**&#x20;
  * **For client/unmanaged services:** Ready to create new sessions using [Start](/api-reference/api-reference/classes/classmedcrypt-guardian-service#function-start) asynchronously.&#x20;
  * **For server services:** Transport is listening and ready to accept connections.
* **Syntax:**

```cpp
bool IsReady()
```

#### IsFailed()

* **Description:** Used for server services when underlying transport fails during listening. Checks if the service is in a failed state.
* **Dependencies:** Used for server services to check transport status
* **Parameters:** None
* **Returns:** Boolean value indicating failure state
  * `true` - The underlying server transport has failed
  * `false` - The underlying server transport has not failed
* **Action:** Service should be shutdown and [Listen](#function-listen) called again.
* **Syntax:**

```cpp
bool IsFailed()
```

#### Listen()

* **Description:**&#x20;
  * Allows a managed server service to listen for new connections.&#x20;
  * Equivalent to calling 'bind' and 'listen' on a server socket.
  * This function is not applicable to unmanaged or client services.
* **Dependencies:** Only applicable to managed server services
* **Parameters:**
  * `in_override`: Null terminated transport specific override string
  * **Default value:** nullptr (no override)
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` - Successfully started listening for connections
  * **Error codes:**
    * `FAIL` - General failure, did not start listening for connections
    * `MISCONFIGURED` - Service is configured as unmanaged or as a a client
* **Action:**&#x20;
  * Starts listening for incoming connections on configured transport.
  * **Example:** zeromq ex: "tcp\://127.0.0.1:12345"
  * &#x20;(default: no override)
* **See also:** "Override Strings" documentation
* **Syntax:**

```cpp
Status Listen(
    const char * in_override =nullptr
)
```

#### ConfigureTransport()

* **Description:**&#x20;
  * Secures the provided transport based on the loaded profile.&#x20;
  * Uses profile configuration to secure and/or enable authentication for the provided transport based on unmanaged service configuration.
* **Dependencies:** Must have loaded profile with transport configuration
* **Parameters:**
  * `in_transport`: Transport to be configured
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` - Successfully configured provided transport
  * **Error codes:**
    * `FAIL` - General failure, transport is unconfigured
    * `BADPARAM` - `in_transport` is empty
    * `MISCONFIGURED` - Profile does not support configuring transport on this service
    * `HANDSHAKEREQUIRED` - Current CertificateManager lacks necessary keys/trust
  * **See also:** "Unmanaged Handshaking" documentation&#x20;
* **Action:** Applies security configuration from profile to the provided transport.
* **See also:** "Unmanaged Handshaking" documentation.&#x20;
* **Syntax:**

```cpp
Status ConfigureTransport(
    std::shared_ptr< TransportInterface > in_transport
)
```

#### Shutdown()

* **Description:**&#x20;
  * Stops all contained connections, blocking for any queued data to send or fail to send.&#x20;
  * Includes all sessions, connections, and channels, even those placed on other threads by [CreateTask](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#createtask-service-variant).
* **Dependencies:** Can be called on active service
* **Parameters:**
  * `in_force`: After the timeout (or immediately if the timeout is 0), drop all waiting data and shut down.
  * **Default value:** `false`
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` - Service is shut down
  * **Error codes:**
    * `FAIL` - General failure. Check the log.
    * `AGAIN` - One or more transports has queued data to send
* **Action:** Stops all contained connections and cleans up resources.
* **Syntax:**

```cpp
Status Shutdown(
    const bool & in_force =false
)
```

#### Start(): No override

* **Description:**&#x20;
  * Starts connection via blocking call.
  * Behavior varies by service type:&#x20;
    * **Managed:**&#x20;
      * **Client services:** Block until connection succeeds/fails.&#x20;
      * **Server services:** Block until client connects.&#x20;
    * **Unmanaged services:** Always succeed unless transport configuration is required and no transport has been provided.
* **Dependencies:** Service must be ready and properly configured
* **Parameters:**
  * `out_session`: Pointer populated with resulting session on success
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` - Successfully started a connection
  * **Error codes:**
    * `FAIL` - Could not connect to endpoint or server service was shut down
    * `BADPARAM` - `out_session` is null pointer
    * `MISCONFIGURED` - Profile has insufficient data to create connection
* **Action:** Creates and establishes a connection, returning a session object.
* **Syntax:**

```cpp
Status Start(
    std::unique_ptr< Session > * out_session
)
```

#### Start(): With override

* **Description:**&#x20;
  * Blocking call to create connection using provided override string.&#x20;
  * Not applicable to server services.
* **Dependencies:** Service must support override strings
* **Parameters:**
  * `in_override`: Transport specific override string, terminated by null
  * `out_session`: Pointer populated with resulting session on success
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` - Successfully started a connection
  * **Error codes:**
    * `FAIL` - Could not connect to endpoint or server service was shutdown
    * `BADPARAM` - out\_session is null pointer
    * `MISCONFIGURED` - Profile has insufficient data or unmanaged connection needs configured transport
    * `DENIED` - This is a server service, override not possible
  * **See also:** All status codes for complete reference
* **Action:** Creates connection using custom transport parameters.
* **Syntax:**

```cpp
Status Start(
    const char * in_override,
    std::unique_ptr< Session > * out_session
)
```

Starts connection using the provided override string(blocking).

**Parameters**:

* **in\_override** null terminated transport specific override string see "Override Strings" documentation. zeromq ex: "tcp\://127.0.0.1:12345", defaults to no override&#x20;
* **out\_session** on success this pointer is populated with the resulting session

**Returns**:

* **OK** successfully started a connection&#x20;
* **FAIL** could not connect to endpoint or server service was shutdown&#x20;
* **BADPARAM** out\_session is nullptr&#x20;
* **MISCONFIGURED** profile has insufficient data to create a connection OR this is an unmanaged connection that needs a configured transport&#x20;
* **DENIED** this is a server service, an override is not possible&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Blocking call to create a connection. Managed: Client: Will block until a connection succeeds or fails. Server: Not applicable.

Unmanaged: This call will always succeed unless the loaded profile requires a configured transport and no transport has been provided.

#### AsyncStart()

* **Description:** Non-blocking call to create connection. Client services return once connection process begins. Server services return waiting client if available. Unmanaged services equivalent to Start().
* **Dependencies:** Service must be ready for connections
* **Parameters:**
  * `out_session`: Pointer populated with resulting session on success
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` - Successfully started the connection process
  * **Error codes:**
    * `FAIL` - Could not connect to endpoint
    * `BADPARAM` - out\_session is null pointer
    * `MISCONFIGURED` - Profile has insufficient data to create connection
    * `AGAIN` - Server only, no client waiting to connect
  * **See also:** All status codes for complete reference
* **Action:** Initiates connection process without blocking.
* **Syntax:**

#### AsyncStart() - With Override

* **Description:** Non-blocking call to create connection using override string. Not applicable to server services already listening.
* **Dependencies:** Service must support override and not be listening server
* **Parameters:**
  * `in_override`: Transport specific override string, terminated by null
  * `out_session`: Pointer populated with resulting session on success
* **Returns:** Status code indicating success or failure.
  * **Success code:** `OK` - Successfully started a connection
  * **Error codes:**
    * `FAIL` - Could not connect to endpoint
    * `BADPARAM` - out\_session is null pointer
    * `MISCONFIGURED` - Profile has insufficient data to create connection
    * `DENIED` - Server service already listening, override not possible
    * `AGAIN` - Server only, no client waiting to connect
  * **See also:** All status codes for complete reference
* **Action:** Initiates connection with custom parameters without blocking.

**Syntax:**

#### ClientWaiting()

* **Description:** Check if a client is waiting to connect (non-blocking). Always returns false for client services.
* **Dependencies:** Only relevant for server services
* **Parameters:** None
* **Returns:** Boolean value indicating client availability
  * `true` - There is a client waiting
  * `false` - No client waiting or this is a client service
* **Action:** If true, AsyncStart() will succeed and Start() will not block.
* **Syntax:**

|                                                                                                                                                  | Name                                                                                                                                                                                                                                                                                                                                                                                              |
| ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|                                                                                                                                                  | <p><a href="/pages/-MD0rw0rvf8xwC5NyFm3#function-~service"><strong>\~Service</strong></a>() <br>The destructor.</p>                                                                                                                                                                                                                                                                               |
| bool                                                                                                                                             | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-service#function-isready"><strong>IsReady</strong></a>() <br>Is the service ready for operation.</p>                                                                                                                                                                                                                      |
| bool                                                                                                                                             | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-service#function-isfailed"><strong>IsFailed</strong></a>() <br>Is the service in a failed state.</p>                                                                                                                                                                                                                      |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-service#function-listen"><strong>Listen</strong></a>(const char \* in\_override =nullptr) <br>Allows a managed server service to listen for new connections.</p>                                                                                                                                                          |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-service#function-configuretransport"><strong>ConfigureTransport</strong></a>(std::shared\_ptr< <a href="/api-reference/api-reference/classes/classmedcrypt-guardian-transportinterface">TransportInterface</a> > in\_transport) <br>Secures the provided transport based on the loaded profile.</p>                       |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-service#function-shutdown"><strong>Shutdown</strong></a>(const bool & in\_force =false) <br>Stops all contained connections, blocking for any queued data to send or fail to send.</p>                                                                                                                                    |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-service#function-start"><strong>Start</strong></a>(std::unique\_ptr< <a href="/api-reference/api-reference/classes/classmedcrypt-guardian-session">Session</a> > \* out\_session) <br>Starts connection (blocking).</p>                                                                                                   |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-service#function-start"><strong>Start</strong></a>(const char <em>in\_override, std::unique\_ptr<</em> <a href="/api-reference/api-reference/classes/classmedcrypt-guardian-session"><em>Session</em></a> <em>></em> out\_session) <br>Starts connection using the provided override string(blocking).</p>                |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-service#function-asyncstart"><strong>AsyncStart</strong></a>(std::unique\_ptr< <a href="/api-reference/api-reference/classes/classmedcrypt-guardian-session">Session</a> > \* out\_session) <br>Starts connection (non-blocking).</p>                                                                                     |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-service#function-asyncstart"><strong>AsyncStart</strong></a>(const char <em>in\_override, std::unique\_ptr<</em> <a href="/api-reference/api-reference/classes/classmedcrypt-guardian-session"><em>Session</em></a> <em>></em> out\_session) <br>Starts connection using the provided override string (non-blocking).</p> |
| bool                                                                                                                                             | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-service#function-clientwaiting"><strong>ClientWaiting</strong></a>() <br>Check if a client is waiting to connect (non-blocking)</p>                                                                                                                                                                                       |

## Public Functions Documentation

###

###

### function Start

```cpp
Status Start(
    std::unique_ptr< Session > * out_session
)
```

Starts connection (blocking).

**Parameters**:

* **out\_session** on success this pointer is populated with the resulting session

**Returns**:

* **OK** successfully started a connection&#x20;
* **FAIL** could not connect to endpoint or server service was shutdown&#x20;
* **BADPARAM** out\_session is nullptr&#x20;
* **MISCONFIGURED** profile has insufficient data to create a connection&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Blocking call to create a connection. Managed: Client: Will block until a connection succeeds or fails. Server: Will block until a client connects.

Unmanaged: This call will always succeed unless the loaded profile requires a configured transport and no transport has been provided.

### function Start

```cpp
Status Start(
    const char * in_override,
    std::unique_ptr< Session > * out_session
)
```

Starts connection using the provided override string(blocking).

**Parameters**:

* **in\_override** null terminated transport specific override string see "Override Strings" documentation. zeromq ex: "tcp\://127.0.0.1:12345", defaults to no override&#x20;
* **out\_session** on success this pointer is populated with the resulting session

**Returns**:

* **OK** successfully started a connection&#x20;
* **FAIL** could not connect to endpoint or server service was shutdown&#x20;
* **BADPARAM** out\_session is nullptr&#x20;
* **MISCONFIGURED** profile has insufficient data to create a connection OR this is an unmanaged connection that needs a configured transport&#x20;
* **DENIED** this is a server service, an override is not possible&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Blocking call to create a connection. Managed: Client: Will block until a connection succeeds or fails. Server: Not applicable.

Unmanaged: This call will always succeed unless the loaded profile requires a configured transport and no transport has been provided.

### function AsyncStart

```cpp
Status AsyncStart(
    std::unique_ptr< Session > * out_session
)
```

Starts connection (non-blocking).

**Parameters**:

* **out\_session** on success this pointer is populated with the resulting session

**Returns**:

* **OK** successfully started the connection process&#x20;
* **FAIL** could not connect to endpoint&#x20;
* **BADPARAM** out\_session was set to nullptr&#x20;
* **MISCONFIGURED** profile has insufficient data to create a connection&#x20;
* **AGAIN** server only, no client waiting to connect, try again&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Non-blocking call to create a connection. Managed: Client: Will return once the underlying connection process has begun or failed. Server: return a waiting client connection if available.

Unmanaged: Equivalent to calling Start.

### function AsyncStart

```cpp
Status AsyncStart(
    const char * in_override,
    std::unique_ptr< Session > * out_session
)
```

Starts connection using the provided override string (non-blocking).

**Parameters**:

* **in\_override** null terminated transport specific override string see "Override Strings" documentation. zeromq ex: "tcp\://127.0.0.1:12345", defaults to no override&#x20;
* **out\_session** on success this pointer is populated with the resulting session

**Returns**:

* **OK** successfully started a connection&#x20;
* **FAIL** could not connect to endpoint&#x20;
* **BADPARAM** out\_session was set to nullptr&#x20;
* **MISCONFIGURED** profile has insufficient data to create a connection&#x20;
* **DENIED** this is a server service that is already listening and an override is not possible&#x20;
* **AGAIN** server only, no client waiting to connect, try again&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Non-blocking call to create a connection. Managed: Client: Will return once the underlying connection process has begun or failed. Server: Not applicable.

Unmanaged: Equivalent to calling Start.

### function ClientWaiting

```cpp
bool ClientWaiting()
```

Check if a client is waiting to connect (non-blocking)

**Parameters**:

* **none**&#x20;

**Returns**:

* **true** there is a client waiting&#x20;
* **false** there is not a client waiting or this is a client service&#x20;

**Return**: bool

If true Async start will succeed and Start will not block. Will always return false for a client service.

## Debugging and logging

Guardian does not create log files. Instead, logging is controlled by the application:

* Guardian logs to `stdout` and `stderr`, which appear in the terminal/CLI of the running application during execution. Look for specific error codes or connection failures in the output.
* **Custom logging:** Use `SetLoggingCallback` to redirect log messages to a callback function, stopping terminal output and allowing custom log handling
* **Log control:** Applications can control log level and verbosity.
* **Guardian Cloud UI**: Check the Guardian Cloud interface for additional error details and provisioning status.


# medcrypt::guardian::Session

Individual connection within a [Service](/api-reference/api-reference/classes/classmedcrypt-guardian-service).

`#include <Session.h>`

## Public Functions

|                                                                                                                                                  | Name                                                                                                                                                                                                                                                                                                                                                                                                             |
| ------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|                                                                                                                                                  | <p><a href="/pages/-MD0rw0swjxc7ttgDQEp#function-~session"><strong>\~Session</strong></a>() <br>The destructor.</p>                                                                                                                                                                                                                                                                                              |
| bool                                                                                                                                             | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-session#function-isready"><strong>IsReady</strong></a>() <br>Are the underlying channels and tranport ready for operation.</p>                                                                                                                                                                                                           |
| bool                                                                                                                                             | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-session#function-isfailed"><strong>IsFailed</strong></a>() <br>Have the underlying transport or channels failed.</p>                                                                                                                                                                                                                     |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-session#function-findchannel"><strong>FindChannel</strong></a>(const char <em>in\_channel\_name, std::unique\_ptr<</em> <a href="/api-reference/api-reference/classes/classmedcrypt-guardian-channelguard"><em>ChannelGuard</em></a> <em>></em> out\_channelguard) <br>Searches for session channel instance based on provided name.</p> |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-session#function-shutdown"><strong>Shutdown</strong></a>(const bool & in\_force =false) <br>Stops contained connection and channelguards, blocking any further data from being queued for send.</p>                                                                                                                                      |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-session#function-dataforsocket"><strong>DataForSocket</strong></a>(char <em>out\_data, size\_t</em> io\_data\_size) <br>Provides data to send over a customer managed transport (blocking)</p>                                                                                                                                           |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-session#function-asyncdataforsocket"><strong>AsyncDataForSocket</strong></a>(char <em>out\_data, size\_t</em> io\_data\_size) <br>Provides data to send over a customer managed transport (non-blocking)</p>                                                                                                                             |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-session#function-datafromsocket"><strong>DataFromSocket</strong></a>(const char \* in\_data, size\_t in\_data\_size) <br>Accepts data to process from a customer managed transport (blocking)</p>                                                                                                                                        |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-session#function-asyncdatafromsocket"><strong>AsyncDataFromSocket</strong></a>(const char \* in\_data, size\_t in\_data\_size) <br>Accepts data to process from a customer managed transport (non-blocking)</p>                                                                                                                          |
| bool                                                                                                                                             | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-session#function-isdatagone"><strong>IsDataGone</strong></a>() <br>Indicates if the session has data waiting to be sent.</p>                                                                                                                                                                                                             |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-session#function-setdataforsocketcallback"><strong>SetDataForSocketCallback</strong></a>(const std::function< bool(const char \*, const size\_t &)> & in\_callback) <br>Registers a callback for sending data through a user managed transport.</p>                                                                                      |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-session#function-setdatafromsocketcallback"><strong>SetDataFromSocketCallback</strong></a>(const std::function< bool(char <em>\*, size\_t</em> )> & in\_callback) <br>Registers a callback for receiving data from a user managed transport.</p>                                                                                         |

## Public Functions Documentation

### function \~Session

```cpp
~Session()
```

The destructor.

**Parameters**:

* **none**&#x20;

**Return**: none

The destructor will not affect the internal [Guardian](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian) representation of the [Session](/api-reference/api-reference/classes/classmedcrypt-guardian-session).

### function IsReady

```cpp
bool IsReady()
```

Are the underlying channels and tranport ready for operation.

**Parameters**:

* **none**&#x20;

**Returns**:

* **true** the session and contained channels are ready to send/receive data&#x20;
* **false** the session and contained channels are not ready to send/receive data&#x20;

**Return**: bool

If the session is ready all contained channels are ready to send and receive data over the contained connected tranport mechanism.

Already received and processed data can still be retrieved through ChannelGuards even if the session is not ready.

### function IsFailed

```cpp
bool IsFailed()
```

Have the underlying transport or channels failed.

**Parameters**:

* **none**&#x20;

**Returns**:

* **true** an error has occurred that is blocking future send/receive operations&#x20;
* **false** no error has occurred&#x20;

**Return**: bool

If the session is failed, it should be destroyed and recreated with Start

Already received and processed data can still be retrieved through ChannelGuards even if the session is failed.

### function FindChannel

```cpp
Status FindChannel(
    const char * in_channel_name,
    std::unique_ptr< ChannelGuard > * out_channelguard
)
```

Searches for session channel instance based on provided name.

**Parameters**:

* **in\_channel\_name** null terminated channel name&#x20;
* **out\_channelguard** pointer to unique\_ptr storage for found channelguard

**Returns**:

* **OK** the pointer in out\_channelguard is valid&#x20;
* **FAIL** could not find the channelguard specified by in\_channel\_name&#x20;
* **BADPARAM** in\_channel\_name is nullptr or empty or out\_channelguard is nullptr&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Uses the loaded profile to secure and/or enable authentication based on unmanged service configuration for the provided transport.

### function Shutdown

```cpp
Status Shutdown(
    const bool & in_force =false
)
```

Stops contained connection and channelguards, blocking any further data from being queued for send.

**Parameters**:

* **in\_force** after the timeout (or immediately if the timeout is 0) drop all waiting data and shutdown.

**Returns**:

* **OK** session is shutdown&#x20;
* **FAIL** general failure, check the log&#x20;
* **AGAIN** one or more transports has queued data to send&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Includes all contained channelguard and any contained transport, even those that have been placed or had a parent placed on another thread by CreateTask.

### function DataForSocket

```cpp
Status DataForSocket(
    char * out_data,
    size_t * io_data_size
)
```

Provides data to send over a customer managed transport (blocking)

**Parameters**:

* **out\_data** binary data buffer to store output data&#x20;
* **io\_data\_size** provide size of provided out\_data buffer, on successful return is set to size of the data in out\_data, on failure is set to 0

**Returns**:

* **OK** out\_data is populated with data to send&#x20;
* **FAIL** general failure, check the log&#x20;
* **BADPARAM** out\_data is nullptr or io\_data\_size is nullptr or 0&#x20;
* **DENIED** session is managed&#x20;
* **OUTOFMEMORY** provided buffer too small&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Blocking call only applicable to unmanaged service sessions. out\_data should be a user allocated buffer to store data intended to be sent over the user managed transport. The call will return immediately under any of the below error conditions, otherwise it will block until data is ready to send.

### function AsyncDataForSocket

```cpp
Status AsyncDataForSocket(
    char * out_data,
    size_t * io_data_size
)
```

Provides data to send over a customer managed transport (non-blocking)

**Parameters**:

* **out\_data** binary data buffer to store output data&#x20;
* **io\_data\_size** provide size of provided out\_data buffer, on successful return is set to size of the data in out\_data, on failure is set to 0

**Returns**:

* **OK** out\_data is populated with data to send&#x20;
* **FAIL** general failure, check the log&#x20;
* **BADPARAM** out\_data is nullptr or io\_data\_size is nullptr or 0&#x20;
* **DENIED** session is managed&#x20;
* **OUTOFMEMORY** provided buffer too small&#x20;
* **AGAIN** there is no data waiting to send, out\_data unmodified&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Non-blocking call only applicable to unmanaged service sessions. out\_data should be a user allocated buffer to store data intended to be sent over the user managed transport.

### function DataFromSocket

```cpp
Status DataFromSocket(
    const char * in_data,
    size_t in_data_size
)
```

Accepts data to process from a customer managed transport (blocking)

**Parameters**:

* **in\_data\_size** size of binary data in in\_data&#x20;
* **in\_data** binary data buffer of received data

**Returns**:

* **OK** in\_data has been processed&#x20;
* **FAIL** unable to process in\_data&#x20;
* **DENIED** session is managed&#x20;
* **OUTOFMEMORY** provided buffer is too large to send&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Blocking call only applicable to unmanaged service sessions. in\_data should contain information received from a customer managed transport. On return data will be available for retrieval from a channelguard.

### function AsyncDataFromSocket

```cpp
Status AsyncDataFromSocket(
    const char * in_data,
    size_t in_data_size
)
```

Accepts data to process from a customer managed transport (non-blocking)

**Parameters**:

* **in\_data\_size** size of binary data in in\_data&#x20;
* **in\_data** binary data buffer of received data

**Returns**:

* **OK** in\_data has been queued for processing or processed&#x20;
* **FAIL** unable to process in\_data&#x20;
* **DENIED** session is managed&#x20;
* **OUTOFMEMORY** provided buffer is too large&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Non-blocking call only applicable to unmanaged service sessions. in\_data should contain information received from a customer managed transport. On return data will may be availble for retrieval from a channelguard.

### function IsDataGone

```cpp
bool IsDataGone()
```

Indicates if the session has data waiting to be sent.

**Parameters**:

* **none**&#x20;

**Returns**:

* **false** data is waiting to be sent&#x20;
* **true** no data is waiting to be sent&#x20;

**Return**: bool

If false there is data waiting to be sent over the contained managed transport or retrieved using \[Async]DataForSocket to be sent over a user managed transport. If false AsyncDataForSocket will return OK and DataForSocket will not block. No guarantees are made on if a non-forcing Shutdown call will block since in a multi-threaded environment more data could be queued for send between a call to IsDataGone and Shutdown.

### function SetDataForSocketCallback

```cpp
Status SetDataForSocketCallback(
    const std::function< bool(const char *, const size_t &)> & in_callback
)
```

Registers a callback for sending data through a user managed transport.

**Parameters**:

* **in\_callback** blocking function that will send data over the user managed transport when called,returns false on failure.

**Returns**:

* **OK** callback registered&#x20;
* **FAIL** general failure&#x20;
* **DENIED** session is managed&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Provides a callback for use with user managed transport and blocking [ChannelGuard](/api-reference/api-reference/classes/classmedcrypt-guardian-channelguard) calls. The provided function must be a blocking call and return only when data has been successfully sent or a failure makes it impossible to send the data.

### function SetDataFromSocketCallback

```cpp
Status SetDataFromSocketCallback(
    const std::function< bool(char **, size_t *)> & in_callback
)
```

Registers a callback for receiving data from a user managed transport.

**Parameters**:

* **in\_callback** blocking function that will receive data from the user managed transport when called, returns false on failure.

**Returns**:

* **OK** callback registered&#x20;
* **FAIL** general failure&#x20;
* **DENIED** session is managed&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Provides a callback for use with user managed transport and blocking [ChannelGuard](/api-reference/api-reference/classes/classmedcrypt-guardian-channelguard) calls. The provided function must be a blocking call and return only when data has been successfully received or a failure makes it impossible to receive data. The callback should follow the same rules for the size\_t parameters as DataFromSocket.

## Debugging and logging

Guardian does not create log files. Instead, logging is controlled by the application:

* Guardian logs to `stdout` and `stderr`, which appear in the terminal/CLI of the running application during execution. Look for specific error codes or connection failures in the output.
* **Custom logging:** Use `SetLoggingCallback` to redirect log messages to a callback function, stopping terminal output and allowing custom log handling
* **Log control:** Applications can control log level and verbosity.
* **Guardian Cloud UI**: Check the Guardian Cloud interface for additional error details and provisioning status.


# medcrypt::guardian::ChannelGuard

Name channel within a [Session](/api-reference/api-reference/classes/classmedcrypt-guardian-channelguard).

`#include <ChannelGuard.h>`

## Public Functions

|                                                                                                                                                  | Name                                                                                                                                                                                                                                                                                           |
| ------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|                                                                                                                                                  | <p><a href="/pages/-MD0rw0tIPg5W3RM6Lnr#function-~channelguard"><strong>\~ChannelGuard</strong></a>() <br>The destructor.</p>                                                                                                                                                                  |
| bool                                                                                                                                             | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-channelguard#function-isready"><strong>IsReady</strong></a>() <br>The <a href="/api-reference/api-reference/classes/classmedcrypt-guardian-channelguard">ChannelGuard</a> is ready to send data.</p>                   |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-channelguard#function-dataforchannel"><strong>DataForChannel</strong></a>(const char \* in\_data, const size\_t & in\_data\_size) <br>Accepts data to encode and send over parent session (blocking)</p>               |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-channelguard#function-asyncdataforchannel"><strong>AsyncDataForChannel</strong></a>(const char \* in\_data, const size\_t & in\_data\_size) <br>Accepts data to encode and send over parent session (non-blocking)</p> |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-channelguard#function-datafromchannel"><strong>DataFromChannel</strong></a>(char <em>out\_data, size\_t</em> io\_data\_size) <br>Returns decoded data received by parent session (blocking)</p>                        |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | [**AsyncDataFromChannel**](/api-reference/api-reference/classes/classmedcrypt-guardian-channelguard#function-asyncdatafromchannel)(char *out\_data, size\_t* io\_data\_size)                                                                                                                   |
| bool                                                                                                                                             | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-channelguard#function-isdatagone"><strong>IsDataGone</strong></a>() <br>Indicates if all data provided to \[Async]DataForChannel has has been sent.</p>                                                                |
| bool                                                                                                                                             | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-channelguard#function-isdatawaiting"><strong>IsDataWaiting</strong></a>() <br>Indicates if there is data waiting to be received with \[Async]DataFromChannel.</p>                                                      |

## Public Functions Documentation

### function \~ChannelGuard

```cpp
~ChannelGuard()
```

The destructor.

**Parameters**:

* **none**&#x20;

**Return**: none

The destructor will not affect the internal [Guardian](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian) representation of the [ChannelGuard](/api-reference/api-reference/classes/classmedcrypt-guardian-channelguard).

### function IsReady

```cpp
bool IsReady()
```

The [ChannelGuard](/api-reference/api-reference/classes/classmedcrypt-guardian-channelguard) is ready to send data.

**Parameters**:

* **none**&#x20;

**Returns**:

* **true** the channel is ready to send data&#x20;
* **false** the channel is not ready to send data&#x20;

**Return**: bool

[ChannelGuard](/api-reference/api-reference/classes/classmedcrypt-guardian-channelguard) will always return any available data with DataFromChannel no matter the internal state. It will block from sending new data unless it is ready.

### function DataForChannel

```cpp
Status DataForChannel(
    const char * in_data,
    const size_t & in_data_size
)
```

Accepts data to encode and send over parent session (blocking)

**Parameters**:

* **in\_data** binary data buffer to encode and send&#x20;
* **in\_data\_size** size of binary data in in\_data

**Returns**:

* **OK** in\_data has been processed&#x20;
* **FAIL** general failure, check log&#x20;
* **BADPARAM** in\_data is nullptr&#x20;
* **OUTOFMEMORY** provided buffer is too large&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Blocking call to send data. When this call completes successfully the provided data has been secured based on the loaded profile and handed to the configured managed network library or unmanaged callback.

If this is a channel in an unmanaged session/service the session must have a registered DataForSocket callback.

### function AsyncDataForChannel

```cpp
Status AsyncDataForChannel(
    const char * in_data,
    const size_t & in_data_size
)
```

Accepts data to encode and send over parent session (non-blocking)

**Parameters**:

* **in\_data** binary data buffer to encode and send&#x20;
* **in\_data\_size** size of binary data in in\_data

**Returns**:

* **OK** in\_data has been processed&#x20;
* **FAIL** general failure, check log&#x20;
* **BADPARAM** in\_data is nullptr&#x20;
* **OUTOFMEMORY** provided buffer is too large&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Non-blocking call to send data. When this call completes successfully the provided data has been secured based on the loaded profile and queued in the parent session to be sent.

### function DataFromChannel

```cpp
Status DataFromChannel(
    char * out_data,
    size_t * io_data_size
)
```

Returns decoded data received by parent session (blocking)

**Parameters**:

* **out\_data** binary data buffer to store output data&#x20;
* **io\_data\_size** provide size of provided out\_data buffer, on a successful return is set to size of the data in out\_data

**Returns**:

* **OK** out\_data is populated with application data&#x20;
* **FAIL** general failure&#x20;
* **BADPARAM** out\_data is nullptr or io\_data\_size is nullptr or 0&#x20;
* **VERIFYFAIL** out\_data may be populated with data but any contained data failed signature verification&#x20;
* **OUTOFMEMORY** provided buffer is too small&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Blocking call to receive data. When this call completes successfully out\_data is populated with valid data.

If this is a channel in an unmanaged session/service the session must have a registered DataFromSocket callback.

### function AsyncDataFromChannel

```cpp
Status AsyncDataFromChannel(
    char * out_data,
    size_t * io_data_size
)
```

**Parameters**:

* **out\_data** binary data buffer to store output data&#x20;
* **io\_data\_size** provide size of provided out\_data buffer, on a successful return is set to size of the data in out\_data

**Returns**:

* **OK** out\_data is populated with application data&#x20;
* **FAIL** general failure&#x20;
* **BADPARAM** out\_data is nullptr or io\_data\_size is nullptr or 0&#x20;
* **VERIFYFAIL** out\_data may be populated with data but any contained data failed signature verification&#x20;
* **OUTOFMEMORY** provided buffer is too small&#x20;
* **AGAIN** no data is currently available, try again&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Returns decoded data received by parent session (non-blocking)

Non-blocking call to receive data. When this call completes successfully out\_data is populated with valid data.

### function IsDataGone

```cpp
bool IsDataGone()
```

Indicates if all data provided to \[Async]DataForChannel has has been sent.

**Parameters**:

* **none**&#x20;

**Returns**:

* **false** data is waiting to be sent&#x20;
* **true** no data is waiting to be sent&#x20;

**Return**: bool

If false there is data that has not been handed to the network layer or user managed transport.

### function IsDataWaiting

```cpp
bool IsDataWaiting()
```

Indicates if there is data waiting to be received with \[Async]DataFromChannel.

**Parameters**:

* **none**&#x20;

**Returns**:

* **false** no data is waiting to be received&#x20;
* **true** data is waiting to be received&#x20;

**Return**: bool

If true \[Async]DataFromChannel will return successfully and DataFromChannel will not block.

## Debugging and logging

Guardian does not create log files. Instead, logging is controlled by the application:

* Guardian logs to `stdout` and `stderr`, which appear in the terminal/CLI of the running application during execution. Look for specific error codes or connection failures in the output.
* **Custom logging:** Use `SetLoggingCallback` to redirect log messages to a callback function, stopping terminal output and allowing custom log handling
* **Log control:** Applications can control log level and verbosity.
* **Guardian Cloud UI**: Check the Guardian Cloud interface for additional error details and provisioning status.


# medcrypt::guardian::SecureOperation

Named standalone operation.

`#include <SecureOperation.h>`

## Public Functions

|                                                                                                                                                  | Name                                                                                                                                                                                                                                                                                                                                       |
| ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|                                                                                                                                                  | <p><a href="/pages/-MD0rw0ukks2kY9K3ns-#function-~secureoperation"><strong>\~SecureOperation</strong></a>() <br>The destructor.</p>                                                                                                                                                                                                        |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-secureoperation#function-sign"><strong>Sign</strong></a>(const char <em>in\_data, const size\_t & in\_data\_size, char</em> out\_signature, size\_t \* io\_signature\_size) <br>Create signature.</p>                                                              |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-secureoperation#function-verify"><strong>Verify</strong></a>(const char <em>in\_data, const size\_t & in\_data\_size, const char</em> in\_signature, const size\_t & in\_signature\_size, bool \* out\_is\_verified) <br>Verify existing signature.</p>            |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-secureoperation#function-signaturemultipartinit"><strong>SignatureMultipartInit</strong></a>(const bool & in\_force =true) <br>Prepare for multipart sign/verify.</p>                                                                                              |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-secureoperation#function-signaturemultipartupdate"><strong>SignatureMultipartUpdate</strong></a>(const char \* in\_data, const size\_t & in\_data\_size) <br>Add data to multipart sign/verify operation.</p>                                                      |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-secureoperation#function-signaturemultipartsignfinal"><strong>SignatureMultipartSignFinal</strong></a>(char <em>out\_signature, size\_t</em> io\_signature\_size) <br>Create signature from previously provided data.</p>                                          |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-secureoperation#function-signaturemultipartverifyfinal"><strong>SignatureMultipartVerifyFinal</strong></a>(const char <em>in\_signature, const size\_t & in\_signature\_size, bool</em> out\_is\_verified) <br>Verify signature from previously provided data.</p> |

## Public Functions Documentation

### function \~SecureOperation

```cpp
~SecureOperation()
```

The destructor.

**Parameters**:

* **none**&#x20;

**Return**: none

The destructor will return the contained object to the main [Guardian](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian) Run thread.

### function Sign

```cpp
Status Sign(
    const char * in_data,
    const size_t & in_data_size,
    char * out_signature,
    size_t * io_signature_size
)
```

Create signature.

**Parameters**:

* **in\_data** binary data buffer&#x20;
* **in\_data\_size** bytes in in\_data&#x20;
* **out\_signature** binary data buffer&#x20;
* **io\_signature\_size** provide size of out\_signature buffer, on return is set to size of the data in out\_signature or the required size of out\_signature

**Returns**:

* **OK** out\_signature populated with the signature&#x20;
* **FAIL** general failure, check the log&#x20;
* **BADPARAM** a provided parameter is nullptr or a size is 0&#x20;
* **MISCONFIGURED** this secure operation is not configured for signatures&#x20;
* **OUTOFMEMORY** out\_signature is too small, see io\_signature\_size for required size&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Signature created based on loaded profile.

### function Verify

```cpp
Status Verify(
    const char * in_data,
    const size_t & in_data_size,
    const char * in_signature,
    const size_t & in_signature_size,
    bool * out_is_verified
)
```

Verify existing signature.

**Parameters**:

* **in\_data** binary data buffer&#x20;
* **in\_data\_size** bytes in in\_data&#x20;
* **in\_signature** binary data buffer&#x20;
* **in\_signature\_size** bytes in in\_signature&#x20;
* **out\_is\_verified** true if in\_data matches in\_signature

**Returns**:

* **OK** signature checked against data, see out\_is\_verified for if signature matched the data&#x20;
* **FAIL** general failure&#x20;
* **BADPARAM** a provided parameter is nullptr or a size is 0&#x20;
* **MISCONFIGURED** this secure operation is not configured for signatures&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Verification based on loaded profile.

Note: return value will be OK for a successful verify operation even if the signature does not match the data. Check out\_is\_verified to see if the data and signature match.

### function SignatureMultipartInit

```cpp
Status SignatureMultipartInit(
    const bool & in_force =true
)
```

Prepare for multipart sign/verify.

**Parameters**:

* **in\_force** optional parameter, true will start a new operation even if another is already in progress

**Returns**:

* **OK** secure operation is ready for data to sign/verify&#x20;
* **FAIL** general failure&#x20;
* **MISCONFIGURED** this secure operation is not configured for signatures&#x20;
* **DENIED** another secure operation is already in progress&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Initializes secure operation for a multipart signature or multipart signature verification.

### function SignatureMultipartUpdate

```cpp
Status SignatureMultipartUpdate(
    const char * in_data,
    const size_t & in_data_size
)
```

Add data to multipart sign/verify operation.

**Parameters**:

* **in\_data\_size** bytes in in\_data&#x20;
* **in\_data** binary data buffer

**Returns**:

* **OK** data added successfully&#x20;
* **FAIL** general failure&#x20;
* **BADPARAM** in\_data is nullptr or in\_data\_size is 0&#x20;
* **DENIED** this secure operation has not been initialized for a multipart sign/verify operation&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

Add data in full or chunked pieces to the secure operation, finish the process with one of the Complete functions.

### function SignatureMultipartSignFinal

```cpp
Status SignatureMultipartSignFinal(
    char * out_signature,
    size_t * io_signature_size
)
```

Create signature from previously provided data.

**Parameters**:

* **io\_signature\_size** provide size of out\_signature buffer, on return is set to size of the data in out\_signature or the required size of out\_signature&#x20;
* **out\_signature** binary data buffer

**Returns**:

* **OK** out\_signature populated with the signature&#x20;
* **FAIL** general failure&#x20;
* **BADPARAM** out\_signature is nullptr or io\_signature\_size is nullptr or 0&#x20;
* **DENIED** multipart signature has not been intiailzed&#x20;
* **OUTOFMEMORY** out\_signature is too small, see io\_signature\_size for required size&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

### function SignatureMultipartVerifyFinal

```cpp
Status SignatureMultipartVerifyFinal(
    const char * in_signature,
    const size_t & in_signature_size,
    bool * out_is_verified
)
```

Verify signature from previously provided data.

**Parameters**:

* **in\_signature\_size** bytes in in\_signature&#x20;
* **in\_signature** binary data buffer&#x20;
* **out\_is\_verified** true if in\_data matches in\_signature

**Returns**:

* **OK** out\_verified reflects if signature matched the data&#x20;
* **FAIL** general failure&#x20;
* **BADPARAM** in\_signature or out\_is\_verified is nullptr or in\_signature\_size is 0&#x20;
* **DENIED** no data has been added to this secure operation&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

## Debugging and logging

Guardian does not create log files. Instead, logging is controlled by the application:

* Guardian logs to `stdout` and `stderr`, which appear in the terminal/CLI of the running application during execution. Look for specific error codes or connection failures in the output.
* **Custom logging:** Use `SetLoggingCallback` to redirect log messages to a callback function, stopping terminal output and allowing custom log handling
* **Log control:** Applications can control log level and verbosity.
* **Guardian Cloud UI**: Check the Guardian Cloud interface for additional error details and provisioning status.


# medcrypt::guardian::Task

Multithreading container.

`#include <Task.h>`

## Public Functions

|                                                                                                                                                  | Name                                                                                                                                                                                                                                                                                                                                  |
| ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|                                                                                                                                                  | <p><a href="/pages/-MD0rw0vImJ-PjwK_KqY#function-~task"><strong>\~Task</strong></a>() <br>The destructor.</p>                                                                                                                                                                                                                         |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-task#function-run"><strong>Run</strong></a>() <br>Runs the contained object.</p>                                                                                                                                                                              |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-task#function-getservice"><strong>GetService</strong></a>(std::unique\_ptr< <a href="/api-reference/api-reference/classes/classmedcrypt-guardian-service">Service</a> > \* out\_service) <br>Returns the contained service.</p>                               |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-task#function-getsession"><strong>GetSession</strong></a>(std::unique\_ptr< <a href="/api-reference/api-reference/classes/classmedcrypt-guardian-session">Session</a> > \* out\_session) <br>Returns the contained session.</p>                               |
| [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-task#function-getchannelguard"><strong>GetChannelGuard</strong></a>(std::unique\_ptr< <a href="/api-reference/api-reference/classes/classmedcrypt-guardian-channelguard">ChannelGuard</a> > \* out\_channelguard) <br>Returns the contained channelguard.</p> |

## Public Functions Documentation

### function \~Task

```cpp
~Task()
```

The destructor.

**Parameters**:

* **none**&#x20;

**Return**: none

The destructor will return the contained object to the main [Guardian](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian) Run thread.

### function Run

```cpp
Status Run()
```

Runs the contained object.

**Parameters**:

* **none**&#x20;

**Returns**:

* **OK** contained object ran successfully&#x20;
* **FAIL** general failure&#x20;
* **SHUTDOWN** the contained object is shutdown&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

This run call should be called by the thread's main loop.

### function GetService

```cpp
Status GetService(
    std::unique_ptr< Service > * out_service
)
```

Returns the contained service.

**Parameters**:

* **out\_service** pointer to unique\_ptr storage for contained service

**Returns**:

* **OK** the pointer in out\_service is valid&#x20;
* **FAIL** general failure&#x20;
* **BADPARAM** out\_service is nullptr&#x20;
* **MISCONFIGURED** the task does not contain a service&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

### function GetSession

```cpp
Status GetSession(
    std::unique_ptr< Session > * out_session
)
```

Returns the contained session.

**Parameters**:

* **out\_session** pointer to unique\_ptr storage for contained session

**Returns**:

* **OK** the pointer in out\_session is valid&#x20;
* **FAIL** general failure
* * **BADPARAM** out\_session is nullptr&#x20;
  * **MISCONFIGURED** the task does not contain a session&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

### function GetChannelGuard

```cpp
Status GetChannelGuard(
    std::unique_ptr< ChannelGuard > * out_channelguard
)
```

Returns the contained channelguard.

**Parameters**:

* **out\_channelguard** pointer to unique\_ptr storage for contained channelguard

**Returns**:

* **OK** the pointer in out\_channelguard is valid&#x20;
* **FAIL** general failure&#x20;
* **BADPARAM** out\_channelguard is nullptr&#x20;
* **MISCONFIGURED** the task does not contain a channelguard&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

## Debugging and logging

Guardian does not create log files. Instead, logging is controlled by the application:

* Guardian logs to `stdout` and `stderr`, which appear in the terminal/CLI of the running application during execution. Look for specific error codes or connection failures in the output.
* **Custom logging:** Use `SetLoggingCallback` to redirect log messages to a callback function, stopping terminal output and allowing custom log handling
* **Log control:** Applications can control log level and verbosity.
* **Guardian Cloud UI**: Check the Guardian Cloud interface for additional error details and provisioning status.


# medcrypt::guardian::TransportInterface

[Service::ConfigureTransport](/api-reference/api-reference/classes/classmedcrypt-guardian-service#function-configuretransport) required interface.

`#include <TransportInterface.h>`

## Public Functions

|                                                                                                                                                          | Name                                                                                                                                                                                                                                                                                 |
| -------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| virtual                                                                                                                                                  | [**\~TransportInterface**](https://docs.medcrypt.com/api-reference/api-reference/classes/pages/-Mgn-MdBHdORu8Qn95JG#function-~transportinterface)()                                                                                                                                  |
| virtual [Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="/api-reference/api-reference/classes/classmedcrypt-guardian-transportinterface#function-applysecurity"><strong>ApplySecurity</strong></a>(const std::unique\_ptr< medcrypt::guardian::utilities::SafeString > & in\_parameters) =0 <br>Security parameters receiver.</p> |

## Public Functions Documentation

### function \~TransportInterface

```cpp
inline virtual ~TransportInterface()
```

### function ApplySecurity

```cpp
virtual Status ApplySecurity(
    const std::unique_ptr< medcrypt::guardian::utilities::SafeString > & in_parameters
) =0
```

Security parameters receiver.

**Parameters**:

* **in\_parameters** implementation dependent encoding of security parameters

**Returns**:

* **OK** successfully applied security&#x20;
* **other** any non zero failure code&#x20;

**Return**: [medcrypt::guardian::Status](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian.md#typedef-status)

The contents of in\_parameters are dependent on the type of transport implemented by the derived class.

An implemented ApplySecurity function should return [GuardianStatusEnum::OK](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian-GuardianStatusEnum.md#enumvalue-ok) on success, and a non zero derivation defined code on failure.

The SafeString type can be treated as a normal std::string.

## Debugging and logging

Guardian does not create log files. Instead, logging is controlled by the application:

* Guardian logs to `stdout` and `stderr`, which appear in the terminal/CLI of the running application during execution. Look for specific error codes or connection failures in the output.
* **Custom logging:** Use `SetLoggingCallback` to redirect log messages to a callback function, stopping terminal output and allowing custom log handling
* **Log control:** Applications can control log level and verbosity.
* **Guardian Cloud UI**: Check the Guardian Cloud interface for additional error details and provisioning status.


# medcrypt::guardian::utilities::InitializeFiles

## Overview

This is the storage for initialization files used to [initialize Guardian](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-2-run-initialize).

**Requirements:**

* All `const char*` inputs should be set to the beginning of the loaded buffer.&#x20;
* All `size_t` inputs should be set to the size of the data loaded in the buffer.

**Usage example:**

* See [GetInitializeFilesFromPath()](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian-utilities.md#function-getinitializefilesfrompath) and [DeleteInitializeFileBuffers()](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Namespaces/namespacemedcrypt-guardian-utilities.md#function-deleteinitializefilebuffers) in [FileHelpers.h](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Files/FileHelpers_8h.md#file-filehelpers.h) for an example of how to use.

**Include:**

```cpp
#include <InitializeFiles.h>
```

**Syntax:**

```cpp
struct medcrypt::guardian::utilities::InitializeFiles;
```

### Structure members

* [TrustStore](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-InitializeFiles.md#variable-truststore): Root certificate authority trust store
* [TrustStoreSize](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-InitializeFiles.md#variable-truststoresize): Device private identity and keys
* [PrivateIdentity](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-InitializeFiles.md#variable-privateidentity): Device private identity and keys
* [PrivateIdentitySize](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-InitializeFiles.md#variable-privateidentitysize): Size of the PrivateIdentity data
* [CertifiedProfile](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-InitializeFiles.md#variable-certifiedprofile): Device certified profile and certificates
* [CertifiedProfileSize](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-InitializeFiles.md#variable-certifiedprofilesize): Size of the CertifiedProfile data
* [CertifiedCertificateRevocations](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-InitializeFiles.md#variable-certifiedcertificaterevocations): Certificate revocation list
* [CertifiedCertificateRevocationsSize](https://github.com/MedCrypt/docs/tree/cc6d7e9e4565d200e300a7e4ea03af7b3d489502/Classes/structmedcrypt-guardian-utilities-InitializeFiles.md#variable-certifiedcertificaterevocationssize): Size of the CertifiedCertificateRevocations data

### Member details

#### TrustStore variable

* **Description:** Root certificate authority TrustStore file buffer for validating certificates.
* **Type:** `const char*`
* **Syntax:**&#x20;

```cpp
const char * TrustStore;
```

#### TrustStoreSize variable

* **Description:** Size of the TrustStore file buffer.
* **Type:** `size_t`
* **Syntax:**

```
size_t TrustStoreSize;
```

#### PrivateIdentity variable

* **Description:** Device private identity containing cryptographic keys.
* **Type:** `const char*`
* **Security:** Must be kept secure and never transmitted.
* **Syntax:**

```cpp
const char * PrivateIdentity;
```

#### PrivateIdentitySize variable

* **Description:** Size of the PrivateIdentity file buffer.
* **Type:** `size_t`
* **Syntax:**

```cpp
size_t PrivateIdentitySize;
```

#### CertifiedProfile variable

* **Description:** Device certified profile containing certificates and configuration.
* **Type:** `const char*`
* **Syntax:**

```cpp
const char * CertifiedProfile;
```

#### CertifiedProfileSize variable

* **Description:** Size of the CertifiedProfile file buffer.
* **Type:** `size_t`
* **Syntax:**

```
size_t CertifiedProfileSize;
```

#### CertifiedCertificateRevocations variable

* **Description:** File buffer for Certificate Revocation List (CRL).
* **Type:** `const char*`
* **Syntax:**

```cpp
const char * CertifiedCertificateRevocations;
```

#### CertifiedCertificateRevocationsSize variable

* **Description:** Size of the CertifiedCertificateRevocations data in bytes.
* **Type:** `size_t`

#### CertifiedCertificateRevocationsSize variable

* **Description:** File buffer size for Certificate Revocation List (CRL).
* **Type:** `const char*`
* **Syntax:**

```cpp
size_t CertifiedCertificateRevocationsSize;
```

### Related classes

* [Guardian class](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#overview): Uses `InitializeFiles` in [Initialize()](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-2-run-initialize) function
* [ProvisionFiles struct](/api-reference/api-reference/classes/structmedcrypt-guardian-utilities-provisionfiles): Similar file structure used for provisioning operations
* [ProvisionOnlineFiles struct](/api-reference/api-reference/classes/structmedcrypt-guardian-utilities-provisiononlinefiles): File structure used for online provisioning

## Debugging and logging

Guardian does not create log files. Instead, logging is controlled by the application:

* Guardian logs to `stdout` and `stderr`, which appear in the terminal/CLI of the running application during execution. Look for specific error codes or connection failures in the output.
* **Custom logging:** Use `SetLoggingCallback` to redirect log messages to a callback function, stopping terminal output and allowing custom log handling
* **Log control:** Applications can control log level and verbosity.
* **Guardian Cloud UI**: Check the Guardian Cloud interface for additional error details and provisioning status.


# medcrypt::guardian::utilities::ProvisionFiles

## Overview

This is the storage for generating provision request files in [GenerateProvisionRequest()](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-3-run-generateprovisionrequest).

**Requirements:**

* **Input:**&#x20;
  * All `const char*` inputs should be set to the beginning of the loaded buffer.&#x20;
  * All `size_t` inputs should be set to the size of the data loaded in the buffer.
* **Output:**&#x20;
  * All `char*` outputs should be set to the beginning of an allocated buffer.&#x20;
  * All `size_t` outputs should be set to the size of the allocated buffer. After success, they will be set to the size of the data written.

**Usage:**&#x20;

* This structure is used with [GenerateProvisionRequest()](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-3-run-generateprovisionrequest) to generate provisioning files.
* See GetProvisionFilesFromPath() and DeleteProvisionFileBuffers() in FileHelpers.h for examples.

**Include:**

```cpp
#include <ProvisionFiles.h>
```

**Syntax:**

```cpp
struct medcrypt::guardian::utilities::ProvisionFiles;
```

### Structure members

**Input members:**

* **TrustStore:** Trust store file buffer
* **TrustStoreSize:** Trust store file buffer size
* **PrivateIdentity:** Private identity file buffer
* **PrivateIdentitySize:** Private identity file buffer size
* **CertifiedProfile:** Certified profile file buffer
* **CertifiedProfileSize:** Certified profile file buffer size
* **CertifiedCertificateRevocations:** Certificate revocations file buffer
* **CertifiedCertificateRevocationsSize:** Certificate revocations file buffer size

**Output members:**

* **ProvisionRequest:** Provision request file buffer
* **ProvisionRequestSize:** Provision request file buffer size
* **GeneratedPrivateIdentity:** Generated private identity file buffer
* **GeneratedPrivateIdentitySize:** Generated private identity file buffer size

### Member details

#### Input members:

#### TrustStore

* **Description:** Trust store file buffer.
* **Type:** `const char*`
* **Usage:** Input
* **Syntax:**

```cpp
const char * TrustStore;
```

#### TrustStoreSize

* **Description:** Trust store file buffer size.
* **Type:** `size_t`
* **Usage:** Input
* **Syntax:**

```cpp
size_t TrustStoreSize;
```

#### PrivateIdentity

* **Description:** Private identity file buffer.
* **Type:** `const char*`
* **Usage:** Input
* **Syntax:**

```cpp
const char * PrivateIdentity;
```

#### PrivateIdentitySize

* **Description:** Private identity file buffer size.
* **Type:** `size_t`
* **Usage:** Input
* **Syntax:**

```cpp
size_t PrivateIdentitySize;
```

#### CertifiedProfile

* **Description:** Certified profile file buffer.
* **Type:** `const char*`
* **Usage:** Input
* **Syntax:**

```cpp
const char * CertifiedProfile;
```

#### CertifiedProfileSize

* **Description:** Certified profile file buffer size.
* **Type:** `size_t`
* **Usage:** Input
* **Syntax:**

```cpp
size_t CertifiedProfileSize;
```

#### CertifiedCertificateRevocations

* **Description:** Certificate revocations file buffer.
* **Type:** `const char*`
* **Usage:** Input
* **Syntax:**

```cpp
const char * CertifiedCertificateRevocations;
```

#### CertifiedCertificateRevocationsSize

* **Description:** Certificate revocations file buffer size.
* **Type:** `size_t`
* **Usage:** Input
* **Syntax:**

```cpp
size_t CertifiedCertificateRevocationsSize;
```

#### Output members:

#### ProvisionRequest

* **Description:** Provision request file buffer.
* **Type:** `char*`
* **Usage:** Output
* **Syntax:**

```cpp
char * ProvisionRequest;
```

#### ProvisionRequestSize

* **Description:** Provision request file buffer size.&#x20;
  * **Input:** allocated buffer size.&#x20;
  * **Output:** actual data size written.
* **Type:** `size_t`
* **Usage:** Input/Output
* **Syntax:**

```cpp
size_t ProvisionRequestSize;
```

#### GeneratedPrivateIdentity

* **Description:** Generated private identity file buffer.
* **Type:** `char*`
* **Usage:** Output
* **Syntax:**

```cpp
char * GeneratedPrivateIdentity;
```

#### GeneratedPrivateIdentitySize

* **Description:** Generated private identity file buffer size.&#x20;
  * **Input:** allocated buffer size.&#x20;
  * **Output:** actual data size written.
* **Type:** `size_t`
* **Usage:** Input/Output
* **Syntax:**

```cpp
size_t GeneratedPrivateIdentitySize;
```

### Related classes

* [Guardian class](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#overview): Uses `ProvisionFiles` in [GenerateProvisionRequest()](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-3-run-generateprovisionrequest)
* [InitializeFiles struct](/api-reference/api-reference/classes/structmedcrypt-guardian-utilities-initializefiles) - Similar file structure used for initialization
* [ProvisionOnlineFiles struct](/api-reference/api-reference/classes/structmedcrypt-guardian-utilities-provisiononlinefiles) - File structure used for online provisioning

## Debugging and logging

Guardian does not create log files. Instead, logging is controlled by the application:

* Guardian logs to `stdout` and `stderr`, which appear in the terminal/CLI of the running application during execution. Look for specific error codes or connection failures in the output.
* **Custom logging:** Use `SetLoggingCallback` to redirect log messages to a callback function, stopping terminal output and allowing custom log handling
* **Log control:** Applications can control log level and verbosity.
* **Guardian Cloud UI**: Check the Guardian Cloud interface for additional error details and provisioning status.


# medcrypt::guardian::utilities::ProvisionOnlineFiles

## Overview

This is the storage for online provisioning files in [StartProvisioningOnline()](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-4-startprovisioningonline).

**Requirements:**

* All `const char*` inputs should be set to the beginning of the loaded buffer.
* All `size_t` inputs should be set to the size of the data loaded in the buffer.

**Usage:**&#x20;

* This structure is used with  [StartProvisioningOnline()](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-4-startprovisioningonline) to provide the provision request for online processing.

**Include:**

```cpp
#include <ProvisionOnlineFiles.h>
```

**Syntax:**

```cpp
struct medcrypt::guardian::utilities::ProvisionOnlineFiles;
```

### Structure members

* **ProvisionRequest:** Provision request file buffer
* **ProvisionRequestSize:** Provision request file buffer size

### Member details

#### ProvisionRequest

* **Description:** Provision request file buffer.
* **Type:** `const char*`
* **Usage:** Input
* **Syntax:**

```cpp
const char * ProvisionRequest;
```

#### ProvisionRequestSize

* **Description:** Provision request file buffer size.
* **Type:** `size_t`
* **Usage:** Input
* **Syntax:**

```cpp
size_t ProvisionRequestSize;
```

### Related classes

* [Guardian class](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#overview):  Uses `ProvisionOnlineFiles` in [StartProvisioningOnline()](/api-reference/api-reference/classes/classmedcrypt-guardian-guardian#step-4-startprovisioningonline).&#x20;
* [ProvisionFiles struct](/api-reference/api-reference/classes/structmedcrypt-guardian-utilities-provisionfiles): File structure used to generate the provision request
* [InitializeFiles struct](/api-reference/api-reference/classes/structmedcrypt-guardian-utilities-initializefiles) - Similar file structure used for initialization

## Debugging and logging

Guardian does not create log files. Instead, logging is controlled by the application:

* Guardian logs to `stdout` and `stderr`, which appear in the terminal/CLI of the running application during execution. Look for specific error codes or connection failures in the output.
* **Custom logging:** Use `SetLoggingCallback` to redirect log messages to a callback function, stopping terminal output and allowing custom log handling
* **Log control:** Applications can control log level and verbosity.
* **Guardian Cloud UI**: Check the Guardian Cloud interface for additional error details and provisioning status.


# User roles and permissions

## Role overview <a href="#administration-columns" id="administration-columns"></a>

You can work with Medcrypt to assign and manage roles for each of your users. [Contact us](mailto:support@medcrypt.co) to add or modify user permissions.

* **Admin:** This role full access to everything in Guardian for your organization.
* **Reporter (Auditing):** This role has view-only access to everything in Guardian for your organization.
* **Limited:** This is a specialized role for third parties who need to provision devices but shouldn't have broader system access.

### Admin role <a href="#admin-role" id="admin-role"></a>

This role has full access to all products and vulnerabilities in the organization and is the only role that can:

* Manage users
* Implement Guardian:&#x20;
  * Download Guardian Library
  * View and export Root of Trust certificates (root and intermediate level)
* Manage device provisioning
  * Approve and reject PRs and complete device provisioning&#x20;
    * [Manual approval type](/manage-devices/manage-device-provisioning#manual-approval-type)
    * [Automatic approval type](/manage-devices/manage-device-provisioning#automatic-approval-type)
  * Export device provisioning report
* View and export root and intermediate certificates

### Reporter (Auditing) role

This role has view-only access to all systems in an organization.&#x20;

* View certificates:
  * View and export root and intermediate certificates
* View systems monitoring
* View device provisioning
  * Export device provisioning report

### Limited role

This is a special role for third parties who need to be able to provision devices at hospitals, but not view anything else. This could be a field engineer.

* Provision devices
  * Upload provision request (PR)
  * Download certified profile (CP)
  * View devices that they have personally provisioned
  * Export device provisioning report


# Modify your organization's name

If you need your organization name modified to accommodate company name changes, mergers, or acquisitions, just [contact us](mailto:support@medcrypt.com)!


# Changelog

{% hint style="info" %}
**Versioning schema**

To get new features to you as quickly as possible, if you are tracking versions in QMS, note that we currently have five versions within our Guardian platform:

* **Web:** User-facing UI
* **Core:** Core infrastructure
* **Arbiter:** Our back-end orchestration service that manages the secure device provisioning lifecycle, handles authentication requests, enforces access policies, and coordinates cryptographic operations between system components.
* **Vault:** Our secure storage service that manages encryption keys, certificates, and sensitive credentials with strict access controls.
* **Guardian Library:** Client-side integration libraries available in multiple language formats (Java, C++, C#, C, Python, Node.js). Library versions may vary depending on the language format you download

**Version ordering**

Versions are listed in the following order: Core | Web | Library | Vault | Arbiter. \
\
**How can I see my Guardian versioning?**

Click **Help > About** in the sidebar to view version information.
{% endhint %}

## 1.4.1 | 2.3.6   <a href="#v4.2.47-or-2.97.2" id="v4.2.47-or-2.97.2"></a>

*June 13, 2025*

### **Summary**

* Manage device provisioning with manual or automatic approval workflows
* Bulk approve or reject provisioning requests to streamline operations
* Enhanced device provisioning filters for better device management

### **Manage device provisioning with manual or automatic approval workflows**

Choose between manual approval for complete control over device provisioning or automatic approval for streamlined operations. Manual mode gives your team review and approval capabilities for each provisioning request, ideal for high-security environments or initial rollouts. Automatic mode processes trusted device requests without intervention, perfect for production environments with established trust policies, reducing manual work and accelerating deployment timelines.

### Bulk approve or reject provisioning requests to streamline operations

Process multiple provisioning requests simultaneously with new bulk operations functionality. This dramatically reduces administrative time for large device deployments, enabling you to quickly get your devices out in the field. Perfect for manufacturing environments deploying hundreds or thousands of devices where individual approval would be time-prohibitive.

### Enhanced device provisioning filters for better device management

Added comprehensive search and filter capabilities for device provisioning activities. Quickly locate specific devices, provisioning statuses, or time-based activities with improved navigation tools. These enhancements reduce time spent managing large device inventories to seconds, improving operational efficiency for teams managing complex device ecosystems.

***

## 1.4.0 | 2.3.5  <a href="#v4.2.47-or-2.97.2" id="v4.2.47-or-2.97.2"></a>

*April 22, 2025*

### Summary

* Add customer-facing manual approval workflow interface
* Enhanced security and integrity checking

### Add customer-facing manual approval workflow

You can now manage approval workflows directly within Guardian's UI, featuring a visual approval pipeline with status tracking, provisioning request review capabilities, and comprehensive audit trail for all approval decisions. This supports FDA cybersecurity documentation requirements with complete approval records and gives teams full visibility into their provisioning process.

### Enhanced security and integrity checking

Added enhanced validation and integrity checking, strengthening the overall security posture of your device provisioning workflow.

## 1.3.0

*April 3, 2025*

### Summary

* Monitor device provisioning with real-time status tracking
* View and export comprehensive provisioning request reports
* Enhanced API performance and reliability
* Enhanced RBAC security

### Monitor device provisioning with real-time status tracking

Track the current provisioning status of all devices in your fleet with real-time monitoring capabilities and historical progression views. Manufacturing teams can monitor production line provisioning, field service teams can track deployment progress, and security teams can audit provisioning compliance. This provides complete visibility into your device deployment pipeline.

### View and export comprehensive provisioning request reports

Customers can now view and [export](#export-device-provisioning-report) a comprehensive device provisioning report showing current device status snapshots and complete provisioning journey documentation for your regulatory documentation requirements. This provides better visibility into device deployment progress, audit trails for compliance requirements, and operational insights for manufacturing and deployment teams to optimize their provisioning processes.&#x20;

### Enhanced API performance and reliability

Optimized all user-facing APIs with improved error handling, reliability, and response consistency. These enhancements provide better reliability for automated workflows and third-party integrations, reducing integration complexity and improving overall system stability.

### Enhanced RBAC security

Enhanced foundational role-based access control infrastructure to support stronger user session security and customer-facing user access management.

## 1.2.3

*February 13, 2025*

### Bug fix

* Fixed issue where download action for Certified Profile was disabled in Actions column of UI

## 1.2.2

*January 14, 2025*

### Bug fix

* Fixed issue where device data of devices provisioning in that session was not populating into the Devices list

## 1.2.1

*December 18, 2024*

### Summary

* Enhanced self-provisioning endpoints for adding self-provisioning to UI in future

### Enhanced self-provisioning endpoints

Made significant backend improvements to self-provisioning capabilities that prepare the foundation for upcoming UI self-provisioning features. These infrastructure enhancements improve API reliability and performance for automated provisioning workflows while setting the stage for more advanced user-facing provisioning capabilities.

## 1.2.0

*November 15, 2024*

### Summary

* Enhanced security and stability of organization verification

### Enhanced security and stability of organization verification

Enhanced security and stability of organization verification processes with better validation of organizational boundaries and access controls.&#x20;

## 1.1.1

*October 4, 2024*

### Summary

* Added support for importing x509 certificates to multiple organizations
* Bug fix

### Added support for importing x509 certificates to multiple organizations

Added capability to import X.509 certificates across multiple organizations, enabling cross-organizational trust relationships and certificate sharing. This supports complex enterprise deployments where devices or systems need to establish trust across different business units or organizational boundaries while maintaining security isolation.

### Bug fix:

* Resolved issue where the certificates API wasn't returning all Certified Profiles&#x20;

## 1.0.3

*September 10, 2024*

### Bug fix

* Fixed key configuration issue with vault signer keys


