acme_client.c File Reference

ACME client (Automatic Certificate Management Environment) More...

Go to the source code of this file.

Macros

#define TRACE_LEVEL   ACME_TRACE_LEVEL
 

Functions

error_t acmeClientInit (AcmeClientContext *context)
 Initialize ACME client context. More...
 
error_t acmeClientRegisterTlsInitCallback (AcmeClientContext *context, AcmeClientTlsInitCallback callback)
 Register TLS initialization callback function. More...
 
error_t acmeClientRegisterCsrCallback (AcmeClientContext *context, AcmeClientCsrCallback callback)
 Register CSR generation callback function. More...
 
error_t acmeClientSetPrng (AcmeClientContext *context, const PrngAlgo *prngAlgo, void *prngContext)
 Set the pseudo-random number generator to be used. More...
 
error_t acmeClientSetTimeout (AcmeClientContext *context, systime_t timeout)
 Set communication timeout. More...
 
error_t acmeClientSetHost (AcmeClientContext *context, const char_t *host)
 Set the domain name of the ACME server. More...
 
error_t acmeClientSetDirectoryUri (AcmeClientContext *context, const char_t *directoryUri)
 Set the URI of the directory object. More...
 
error_t acmeClientBindToInterface (AcmeClientContext *context, NetInterface *interface)
 Bind the ACME client to a particular network interface. More...
 
error_t acmeClientConnect (AcmeClientContext *context, const IpAddr *serverIpAddr, uint16_t serverPort)
 Establish a connection with the specified ACME server. More...
 
error_t acmeClientSetAccountKey (AcmeClientContext *context, const char_t *publicKey, size_t publicKeyLen, const char_t *privateKey, size_t privateKeyLen)
 Load account key pair. More...
 
error_t acmeClientCreateAccount (AcmeClientContext *context, const AcmeAccountParams *params)
 Account creation. More...
 
error_t acmeClientUpdateAccount (AcmeClientContext *context, const AcmeAccountParams *params)
 Account information update. More...
 
error_t acmeClientChangeAccountKey (AcmeClientContext *context, const char_t *publicKey, size_t publicKeyLen, const char_t *privateKey, size_t privateKeyLen)
 Account key rollover. More...
 
error_t acmeClientDeactivateAccount (AcmeClientContext *context)
 ACME account deactivation. More...
 
error_t acmeClientCreateOrder (AcmeClientContext *context, const AcmeOrderParams *params)
 Begin the certificate issuance process. More...
 
const char_tacmeClientGetHttpKeyAuthorization (AcmeClientContext *context, const char_t *token)
 Get the key authorization that matches a given token (HTTP challenge) More...
 
const char_tacmeClientGetDnsKeyAuthorization (AcmeClientContext *context, const char_t *identifier)
 Get the key authorization digest that matches a given identifier (DNS challenge) More...
 
const char_tacmeClientGetTlsAlpnCertificate (AcmeClientContext *context, const char_t *identifier)
 Get the self-certificate that matches a given identifier (TLS-ALPN challenge) More...
 
error_t acmeClientPollOrderStatus (AcmeClientContext *context, AcmeOrderStatus *orderStatus)
 Poll for order status. More...
 
error_t acmeClientDownloadCertificate (AcmeClientContext *context, char_t *buffer, size_t size, size_t *length)
 Download the certificate. More...
 
error_t acmeClientRevokeCertificate (AcmeClientContext *context, const char_t *cert, size_t certLen, const char_t *privateKey, size_t privateKeyLen, AcmeReasonCode reason)
 Certificate revocation. More...
 
error_t acmeClientDisconnect (AcmeClientContext *context)
 Gracefully disconnect from the ACME server. More...
 
error_t acmeClientClose (AcmeClientContext *context)
 Close the connection with the ACME server. More...
 
void acmeClientDeinit (AcmeClientContext *context)
 Release ACME client context. More...
 

Detailed Description

ACME client (Automatic Certificate Management Environment)

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2019-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneACME Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Description

ACME is a protocol that a CA and an applicant can use to automate the process of verification and certificate issuance. The protocol also provides facilities for other certificate management functions, such as certificate revocation. Refer to the following RFCs for complete details:

  • RFC 8555: Automatic Certificate Management Environment (ACME)
  • RFC 8737: ACME TLS Application-Layer Protocol Negotiation (ALPN) Challenge Extension
  • RFC 7515: JSON Web Signature (JWS)
  • RFC 7517: JSON Web Key (JWK)
  • RFC 7518: JSON Web Algorithms (JWA)
  • RFC 7638: JSON Web Key (JWK) Thumbprint
Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

Definition in file acme_client.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   ACME_TRACE_LEVEL

Definition at line 45 of file acme_client.c.

Function Documentation

◆ acmeClientBindToInterface()

error_t acmeClientBindToInterface ( AcmeClientContext context,
NetInterface interface 
)

Bind the ACME client to a particular network interface.

Parameters
[in]contextPointer to the ACME client context
[in]interfaceNetwork interface to be used
Returns
Error code

Definition at line 249 of file acme_client.c.

◆ acmeClientChangeAccountKey()

error_t acmeClientChangeAccountKey ( AcmeClientContext context,
const char_t publicKey,
size_t  publicKeyLen,
const char_t privateKey,
size_t  privateKeyLen 
)

Account key rollover.

Parameters
[in]contextPointer to the ACME client context
[in]publicKeyNew public key (PEM format)
[in]publicKeyLenLength of the new public key
[in]privateKeyNew private key (PEM format)
[in]privateKeyLenLength of the new private key
Returns
Error code

Definition at line 652 of file acme_client.c.

◆ acmeClientClose()

error_t acmeClientClose ( AcmeClientContext context)

Close the connection with the ACME server.

Parameters
[in]contextPointer to the ACME client context
Returns
Error code

Definition at line 1746 of file acme_client.c.

◆ acmeClientConnect()

error_t acmeClientConnect ( AcmeClientContext context,
const IpAddr serverIpAddr,
uint16_t  serverPort 
)

Establish a connection with the specified ACME server.

Parameters
[in]contextPointer to the ACME client context
[in]serverIpAddrIP address of the ACME server to connect to
[in]serverPortPort number
Returns
Error code

Definition at line 272 of file acme_client.c.

◆ acmeClientCreateAccount()

error_t acmeClientCreateAccount ( AcmeClientContext context,
const AcmeAccountParams params 
)

Account creation.

Parameters
[in]contextPointer to the ACME client context
[in]paramsAccount information
Returns
Error code

Definition at line 424 of file acme_client.c.

◆ acmeClientCreateOrder()

error_t acmeClientCreateOrder ( AcmeClientContext context,
const AcmeOrderParams params 
)

Begin the certificate issuance process.

Parameters
[in]contextPointer to the ACME client context
[in]paramsCertificate order information
Returns
Error code

Definition at line 881 of file acme_client.c.

◆ acmeClientDeactivateAccount()

error_t acmeClientDeactivateAccount ( AcmeClientContext context)

ACME account deactivation.

Parameters
[in]contextPointer to the ACME client context
Returns
Error code

Definition at line 769 of file acme_client.c.

◆ acmeClientDeinit()

void acmeClientDeinit ( AcmeClientContext context)

Release ACME client context.

Parameters
[in]contextPointer to the ACME client context

Definition at line 1767 of file acme_client.c.

◆ acmeClientDisconnect()

error_t acmeClientDisconnect ( AcmeClientContext context)

Gracefully disconnect from the ACME server.

Parameters
[in]contextPointer to the ACME client context
Returns
Error code

Definition at line 1680 of file acme_client.c.

◆ acmeClientDownloadCertificate()

error_t acmeClientDownloadCertificate ( AcmeClientContext context,
char_t buffer,
size_t  size,
size_t *  length 
)

Download the certificate.

Parameters
[in]contextPointer to the ACME client context
[out]bufferPointer to the buffer where to store the certificate chain
[in]sizeSize of the buffer, in bytes
[out]lengthActual length of the certificate chain, in bytes
Returns
Error code

Definition at line 1454 of file acme_client.c.

◆ acmeClientGetDnsKeyAuthorization()

const char_t* acmeClientGetDnsKeyAuthorization ( AcmeClientContext context,
const char_t identifier 
)

Get the key authorization digest that matches a given identifier (DNS challenge)

Parameters
[in]contextPointer to the ACME client context
[in]identifierNULL-terminated string that contains the domain name
Returns
The function returns a NULL-terminated string that contains the Base64url-encoded digest of the key authorization if the identifier is valid. Else, the NULL pointer is returned

Definition at line 1084 of file acme_client.c.

◆ acmeClientGetHttpKeyAuthorization()

const char_t* acmeClientGetHttpKeyAuthorization ( AcmeClientContext context,
const char_t token 
)

Get the key authorization that matches a given token (HTTP challenge)

Parameters
[in]contextPointer to the ACME client context
[in]tokenNULL-terminated string that contains the token
Returns
The function returns a NULL-terminated string that contains the key authorization if the token is valid. Else, the NULL pointer is returned

Definition at line 1033 of file acme_client.c.

◆ acmeClientGetTlsAlpnCertificate()

const char_t* acmeClientGetTlsAlpnCertificate ( AcmeClientContext context,
const char_t identifier 
)

Get the self-certificate that matches a given identifier (TLS-ALPN challenge)

Parameters
[in]contextPointer to the ACME client context
[in]identifierNULL-terminated string that contains the domain name
Returns
The function returns a NULL-terminated string that contains the TLS-ALPN certificate if the identifier is valid. Else, the NULL pointer is returned

Definition at line 1153 of file acme_client.c.

◆ acmeClientInit()

error_t acmeClientInit ( AcmeClientContext context)

Initialize ACME client context.

Parameters
[in]contextPointer to the ACME client context
Returns
Error code

Definition at line 69 of file acme_client.c.

◆ acmeClientPollOrderStatus()

error_t acmeClientPollOrderStatus ( AcmeClientContext context,
AcmeOrderStatus orderStatus 
)

Poll for order status.

Parameters
[in]contextPointer to the ACME client context
[out]orderStatusOrder status
Returns
Error code

Definition at line 1202 of file acme_client.c.

◆ acmeClientRegisterCsrCallback()

error_t acmeClientRegisterCsrCallback ( AcmeClientContext context,
AcmeClientCsrCallback  callback 
)

Register CSR generation callback function.

Parameters
[in]contextPointer to the ACME client context
[in]callbackTLS initialization callback function
Returns
Error code

Definition at line 130 of file acme_client.c.

◆ acmeClientRegisterTlsInitCallback()

error_t acmeClientRegisterTlsInitCallback ( AcmeClientContext context,
AcmeClientTlsInitCallback  callback 
)

Register TLS initialization callback function.

Parameters
[in]contextPointer to the ACME client context
[in]callbackTLS initialization callback function
Returns
Error code

Definition at line 108 of file acme_client.c.

◆ acmeClientRevokeCertificate()

error_t acmeClientRevokeCertificate ( AcmeClientContext context,
const char_t cert,
size_t  certLen,
const char_t privateKey,
size_t  privateKeyLen,
AcmeReasonCode  reason 
)

Certificate revocation.

Parameters
[in]contextPointer to the ACME client context
[in]certCertificate to be revoked (PEM format)
[in]certLenLength of the certificate, in bytes
[in]privateKeyReserved parameter (must be NULL)
[in]privateKeyLenReserved parameter (must be 0)
[in]reasonRevocation reason code
Returns
Error code

Definition at line 1574 of file acme_client.c.

◆ acmeClientSetAccountKey()

error_t acmeClientSetAccountKey ( AcmeClientContext context,
const char_t publicKey,
size_t  publicKeyLen,
const char_t privateKey,
size_t  privateKeyLen 
)

Load account key pair.

Parameters
[in]contextPointer to the ACME client context
[in]publicKeyPublic key (PEM format)
[in]publicKeyLenLength of the public key
[in]privateKeyPrivate key (PEM format)
[in]privateKeyLenLength of the private key
Returns
Error code

Definition at line 397 of file acme_client.c.

◆ acmeClientSetDirectoryUri()

error_t acmeClientSetDirectoryUri ( AcmeClientContext context,
const char_t directoryUri 
)

Set the URI of the directory object.

Parameters
[in]contextPointer to the ACME client context
[in]directoryUriNULL-terminated string containing the directory URI
Returns
Error code

Definition at line 223 of file acme_client.c.

◆ acmeClientSetHost()

error_t acmeClientSetHost ( AcmeClientContext context,
const char_t host 
)

Set the domain name of the ACME server.

Parameters
[in]contextPointer to the ACME client context
[in]hostNULL-terminated string containing the host name
Returns
Error code

Definition at line 198 of file acme_client.c.

◆ acmeClientSetPrng()

error_t acmeClientSetPrng ( AcmeClientContext context,
const PrngAlgo prngAlgo,
void *  prngContext 
)

Set the pseudo-random number generator to be used.

Parameters
[in]contextPointer to the ACME client context
[in]prngAlgoPRNG algorithm
[in]prngContextPointer to the PRNG context
Returns
Error code

Definition at line 153 of file acme_client.c.

◆ acmeClientSetTimeout()

error_t acmeClientSetTimeout ( AcmeClientContext context,
systime_t  timeout 
)

Set communication timeout.

Parameters
[in]contextPointer to the ACME client context
[in]timeoutTimeout value, in milliseconds
Returns
Error code

Definition at line 177 of file acme_client.c.

◆ acmeClientUpdateAccount()

error_t acmeClientUpdateAccount ( AcmeClientContext context,
const AcmeAccountParams params 
)

Account information update.

Parameters
[in]contextPointer to the ACME client context
[in]paramsUpdated account information
Returns
Error code

Definition at line 536 of file acme_client.c.