Integration with Certificate Enroll
Overview
In this tutorial, you’ll learn how to integrate Certificate Enroll, a Redtrust service that allows applications to securely generate keys and request the issuance of digital certificates from a controlled environment.
This tutorial is intended for developers from Redtrust partners who have the capability to issue certificates and want to integrate with the Redtrust enrollment service. It assumes you have basic knowledge of HTTP APIs, bearer token authentication, and digital certificates.
Background
This integration allows a Redtrust partner with certificate issuance capabilities to securely generate the keys on the Redtrust server and ultimately generate the digital certificates.
Certificate Enroll handles the entire certificate issuance flow, including:
- User authentication
- Token issuance
- Key generation
- Certificate request and renewal
The integration flow consists of two main phases:
-
Authentication and token acquisition:
The user authenticates against Redtrust, which issues a JWT (JSON Web Token) to authorize access. -
Key generation and certificate issuance:
You use API endpoints to complete the issuance process.
Before you start
To integrate with the new service, you need the following information provided by the Redtrust client:
- IP address or hostname of the Redtrust server.
- The port used to access Sign Service (default is
8083). - Name of the application user for the service.
- (Optional) Domain name.
You will also need the following information provided by the client application's operator:
- Redirect URL where the temporary credentials will be sent. This address must be registered in Redtrust to authorize the redirection target and is essential to obtain the final token (JWT).
Step 1: Authentication and token acquisition
Authentication request
Access the service URL.
https://[HOSTNAME_OR_IP]:[PORT]/authclient/auth/loginrequest?Consumer=RA_API&Domain=[DOMAIN]&RedirectUrl=[REDIRECT_URL]×tamp=[TIMESTAMP]&partner=[PARTNER_NAME]&hmac=[HMAC_SIGNATURE]
For example:
https://localhost:8083/authclient/auth/loginrequest?Consumer=RA_API&Domain=local.users&RedirectUrl=https%3A%2F%2Fgoogle.es%3Ftkn%3D×tamp=1744719496&partner=CA_DEMO&hmac=c360b2d221a55da777a5ba75264d8800ce6ebe89f41aa8b6da7e1a78bb601055
For a list of supported parameters, see Supported parameters.
Required headers
To ensure the legitimacy of each request, you must include the following HTTP headers:
| Header | Description |
|---|---|
x-partner-name | The name of the client application, written in uppercase. This is used to identify and authorize the calling partner. |
x-request-timestamp | A UNIX timestamp indicating when the request is made. This helps prevent replay attacks. See Unix TimeStamp - Epoch Converter. |
x-hmac-signature | A cryptographic signature used to validate the request. It is generated by signing the message PARTNER_NAME:UNIX_TIMESTAMP using the HMAC-SHA256 algorithm with a shared secret. |
The x-hmac-signature allows the server to verify the authenticity and integrity of the request using the same shared secret. Any request with a missing, malformed, or invalid signature will be rejected.
Redirection with temporary token
If authentication completes successfully, the server automatically redirects the user to the provided URL and appends the tkn parameter:
https://your-app.com?tkn=TEMPORARY_TOKEN
Your application must intercept this tkn parameter in the redirected URL. This temporary credential must then be exchanged for a permanent access token and refresh token by calling a specific token endpoint (see step 2).
Step 2: Token exchange
To complete the authentication, you must exchange the temporary token (tkn) received during redirection for an access token and a refresh token. This is done using the endpoints below:
Endpoint: /authapi/v1/login_by_temp_token
Method: GET
Authentication: Authorization: Bearer <accessToken>
Body:
{
"temporalToken": "string"
}
Response
{
"message": "string",
"messageType": "SUCCESS",
"errorCode": "ERROR_CODE",
"data": {
"refreshToken": "string",
"accessToken": "string",
"expiration": "<dateTime>"
}
}
Endpoint: /authapi/v1/refresh-token
Method: PUT
Authentication: Authorization: Bearer <accessToken>
Content-Type: application/json
Body:
{
"refreshToken": "string"
}