Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
SharkTrustX.h
Go to the documentation of this file.
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * Barracuda Embedded Web-Server
10 ****************************************************************************
11 * PROGRAM MODULE
12 *
13 * $Id: SharkTrustX.h 6657 2026-10-28 18:19:39Z wini $
14 *
15 * COPYRIGHT: Real Time Logic LLC, 2026
16 *
17 * This software is copyrighted by and is the sole property of Real
18 * Time Logic LLC. All rights, title, ownership, or other interests in
19 * the software remain the property of Real Time Logic LLC. This
20 * software may only be used in accordance with the terms and
21 * conditions stipulated in the corresponding license agreement under
22 * which the software has been supplied. Any unauthorized use,
23 * duplication, transmission, distribution, or disclosure of this
24 * software is expressly forbidden.
25 *
26 * This Copyright notice may not be removed or modified without prior
27 * written consent of Real Time Logic LLC.
28 *
29 * Real Time Logic LLC. reserves the right to modify this software
30 * without notice.
31 *
32 * https://realtimelogic.com
33 ****************************************************************************
34 */
35
36#ifndef SharkTrustX_h
37#define SharkTrustX_h
38
39#include <HttpServer.h>
40#include <BaTimer.h>
41#include <IoIntf.h>
42#include <SharkSSL.h>
43#include <stddef.h>
44
45#if SHARKSSL_PSA_CONSUMER
46/* Reserve three consecutive persistent IDs exclusively for this client's
47 * private IoIntf store: account, certificate A, certificate B. Override for
48 * a platform's key allocation. Do not share this range with another store. */
49#ifndef SHARKTRUSTX_PSA_KEY_BASE
50#define SHARKTRUSTX_PSA_KEY_BASE 0x23545800
51#endif
52#if SHARKTRUSTX_PSA_KEY_BASE < 1 || SHARKTRUSTX_PSA_KEY_BASE > 0x3ffffffd
53#error SharkTrustX requires three application PSA key IDs
54#endif
55#endif
56
83#ifdef __cplusplus
84extern "C" {
85#endif
86
91typedef enum SharkTrustX_Code
92{
104
111typedef int (*SharkTrustX_Proof)(const unsigned char* message,
112 size_t messageLen, unsigned char proof[32]);
113
122typedef void (*SharkTrustX_Event)(void* context, int code);
123
132typedef void (*SharkTrustX_Name)(void* context, const char* name, size_t length);
133
139typedef struct SharkTrustX_Config
140{
144 SharkSsl* clientSsl;
145 const char* portalDomain;
146 const unsigned char* zoneKey;
148 const char* name;
151 const char* directoryUrl;
154 const char* email;
156 const char* interfaceName;
164 void* context;
166
178BA_API int SharkTrustX_start(const SharkTrustX_Config* config);
179
183typedef struct SharkTrustX_Status
184{
193
204
214BA_API int SharkTrustX_setIpAddress(const char* address);
215
234BA_API int SharkTrustX_clean(IoIntf* io, BaBool all,
235 SharkTrustX_Event onClean, void* context);
236
237#ifdef __cplusplus
238}
239#endif
240#endif
struct SharkTrustX_Status SharkTrustX_Status
Snapshot of the certificate currently served by the managed listeners.
int(* SharkTrustX_Proof)(const unsigned char *message, size_t messageLen, unsigned char proof[32])
Compute the portal proof using generated tokengen code.
Definition: SharkTrustX.h:111
struct SharkTrustX_Config SharkTrustX_Config
Required integration objects and provisioning information.
void(* SharkTrustX_Event)(void *context, int code)
Receive one numeric event.
Definition: SharkTrustX.h:122
BA_API int SharkTrustX_setIpAddress(const char *address)
Ask the active client to publish a changed local IPv4 address.
BA_API BaBool SharkTrustX_getStatus(SharkTrustX_Status *status)
Copy current certificate status without network or storage operations.
SharkTrustX_Code
Numeric lifecycle notifications and errors.
Definition: SharkTrustX.h:92
@ SharkTrustX_Storage
Cannot read, commit, or clean local state.
Definition: SharkTrustX.h:97
@ SharkTrustX_Retry
A retry follows the preceding negative event.
Definition: SharkTrustX.h:94
@ SharkTrustX_Identity
Saved identity, name, or provider mismatch.
Definition: SharkTrustX.h:96
@ SharkTrustX_Acme
ACME account, order, or authorization failure.
Definition: SharkTrustX.h:99
@ SharkTrustX_Crypto
Allocation, key, signing, or listener failure.
Definition: SharkTrustX.h:101
@ SharkTrustX_Busy
A client or cleanup already owns the lifecycle.
Definition: SharkTrustX.h:95
@ SharkTrustX_Terms
Public CA terms were not accepted.
Definition: SharkTrustX.h:102
@ SharkTrustX_Portal
Invalid configuration or portal/DNS failure.
Definition: SharkTrustX.h:98
@ SharkTrustX_Ready
Usable certificate installed; renewal scheduled.
Definition: SharkTrustX.h:93
@ SharkTrustX_Trust
HTTPS peer did not pass trust/name/date checks.
Definition: SharkTrustX.h:100
BA_API int SharkTrustX_start(const SharkTrustX_Config *config)
Start registration, certificate installation, and automatic renewal.
void(* SharkTrustX_Name)(void *context, const char *name, size_t length)
Receive the portal-confirmed DNS name, independently of HTTPS readiness.
Definition: SharkTrustX.h:132
BA_API int SharkTrustX_clean(IoIntf *io, BaBool all, SharkTrustX_Event onClean, void *context)
Stop work, close the managed listener, and erase owned certificate state.
uint16_t U16
Unsigned 16-bit integer.
Definition: GenPrimT.h:94
S64 BaTime
An arithmetic type representing calendar time with epoch of 1970-01-01 00:00:00 UTC,...
Definition: GenPrimT.h:106
U8 BaBool
Boolean stored in an unsigned byte; FALSE is zero and TRUE is one.
Definition: GenPrimT.h:121
Timer manager used for one-shot and periodic callbacks.
Definition: BaTimer.h:67
Route and process HTTP requests using a borrowed dispatcher.
Definition: HttpServer.h:3463
The IoIntf class specifies an abstract file API, implementations include ZipIo, DiskIo,...
Definition: IoIntf.h:482
Required integration objects and provisioning information.
Definition: SharkTrustX.h:140
const char * name
Preferred hostname label, 1..63 ASCII letters/digits/hyphens; no leading/trailing hyphen.
Definition: SharkTrustX.h:148
U16 port
Required unused HTTPS port, 1..65535, normally 443.
Definition: SharkTrustX.h:160
const char * interfaceName
Optional bind address passed to both listener attempts; NULL selects all interfaces.
Definition: SharkTrustX.h:156
BaBool acceptTerms
Must be TRUE publicly; ignored privately.
Definition: SharkTrustX.h:155
SharkTrustX_Name onName
Optional confirmed-name callback, or NULL.
Definition: SharkTrustX.h:163
BaTimer * timer
Required dedicated timer using the server's mutex.
Definition: SharkTrustX.h:142
const char * email
Required contact email in public builds; ignored privately.
Definition: SharkTrustX.h:154
SharkSsl * clientSsl
Required client TLS context with trusted CA list.
Definition: SharkTrustX.h:144
const unsigned char * zoneKey
Required borrowed 32-byte tokengen zone key.
Definition: SharkTrustX.h:146
const char * portalDomain
Required tokengen domain only, without scheme/path.
Definition: SharkTrustX.h:145
SharkTrustX_Proof proof
Required tokengen proof callback.
Definition: SharkTrustX.h:147
HttpServer * server
Required initialized server with running dispatcher.
Definition: SharkTrustX.h:141
void * context
Optional borrowed application pointer for both callbacks.
Definition: SharkTrustX.h:164
SharkTrustX_Event onEvent
Optional status callback, or NULL.
Definition: SharkTrustX.h:162
const char * directoryUrl
Required absolute HTTPS ACME directory in public builds.
Definition: SharkTrustX.h:151
IoIntf * io
Required private writable state store; see Store keys and enrollment safely.
Definition: SharkTrustX.h:143
Snapshot of the certificate currently served by the managed listeners.
Definition: SharkTrustX.h:184
BaBool ready
TRUE when at least one listener has an unexpired certificate.
Definition: SharkTrustX.h:185
BaTime expires
Certificate expiry, UTC Unix seconds; zero if not ready.
Definition: SharkTrustX.h:187
BaTime renew
Renewal due time, UTC Unix seconds; zero if not ready.
Definition: SharkTrustX.h:188