This article describes a configuration example of the Certificate Manager (CM) REST API in Protocol Gateway.
Access to the REST API requires use of TLS with certificate-based client authentication, and an API request is signed using an officer certificate.
Prerequisites
-
Ensure that JDK 21 is configured, as it is required for ‘testtools client’.
-
Protocol Gateway must be installed. See Install Protocol Gateway.
-
Initial configuration of Protocol Gateway must be done. See Initial configuration of Protocol Gateway.
-
Tomcat must be configured for TLS client authentication. See Configure Tomcat for TLS client authentication in Protocol Gateway.
Configure REST API
Create certificate procedure for CM REST API devices
If a new certificate procedure is needed for REST API devices, then create one according to Create certificate procedure in Certificate Manager with the following settings:
-
Set Issuing CA to Device Issuing CA.
-
Set Format to rfc5280.
Create token procedures for CM REST API devices
Token procedures must be set up for the needed REST API use cases. In this example two token procedures are created: One for PKCS#12 responses and one for PKCS#7 or X.509 DER/PEM certificate encoded responses, both from a PKCS#10 request.
Create two new device token procedures and one new VRO token procedure for REST API devices, according to Create token procedure in Certificate Manager with the following settings:
-
For PKCS#12 responses from a PKCS#10 request:
-
Set Procedure name to Device Token Procedure P12.
-
In Storage profile, select PKCS12.
-
In Issuer certificates, select to Store all or Do not store any.
-
-
For PKCS#7 or X.509 DER/PEM encoded certificate responses from a PKCS#10 request:
-
Set Procedure name to Device Token Procedure P10.
-
In Storage profile, select PKCS10.
-
In Issuer certificates, select to Store all or Do not store any.
-
-
For authority create VRO:
-
Create a VRO 'api_vro.p12' using VRO Token Procedure
-
Create an officer ‘testclient_officer' and assign the 'api_vro’ certificate to it.
-
Copy the 'api_vro.p12' under \testtools\temp\api_vro.p12
-
Set REST API properties
To set the properties for the REST API:
-
Open api.properties for editing.
-
Modify the following properties:
-
Enable the REST API by setting
starttotrue. -
Set the token procedures for the needed use cases. For example, set token procedures for
handler.30andhandler.31to the token procedures that were created in the previous step.
-
For more information on how to configure verifications of certificate requests in .properties files, see Certificate request verifications in Protocol Gateway.
-
If needed, scramble sensitive parameters in the configuration file. See Scramble sensitive data in configuration files in Protocol Gateway.
-
Save the file.
Example: api.properties
start = true
# Process PKCS10 request
handler.30.filter = certificates/pkcs10
handler.30.format = api/certificates-pkcs10
handler.30.tokenprocedure = Device Token Procedure P10
# Process PKCS10 request -> PKCS12 response
handler.31.filter = certificates/pkcs10-to-pkcs12
handler.31.format = api/certificates-pkcs10-to-pkcs12
handler.31.tokenprocedure = Device Token Procedure P12
Restart Tomcat
Restart the Tomcat service.
Verify REST API
Prepare test of REST API
Use testtools to verify the REST API located in build package “\Installation\clients\cm_clients_<version>\program_files\web\testtools\” :
-
Copy the file api_vro.p12 to /testtools/temp/.
-
Copy the issuing CA, SystemCA.cer to /testtools/certs.
-
Configure the REST API test client by editing /testtools/config/com.nexussafe.cm.test.app.APIClient.properties, and set:
p12.keyToken.keyFile = temp/api_vro.p12 p12.keyToken.password = 1234
-
To test that the client is working, execute the following command from the testtools directory:
bin\testtools APICLIENT list-procedures
Create a sample CSR
To create a PKCS#10 certificate signing request (CSR):
-
Run the following OpenSSL command:
Bashopenssl req -new -newkey rsa:2048 -nodes -keyout key.pem -out csr.p10 -subj "/CN=Test/O=Example/C=SE" -
This creates a CSR file, csr.p10, and a private key, key.pem, with sample data.
-
Alternatively, if OpenSSL is not available, use Java keytool:
Bashkeytool -genkeypair -alias test -keyalg RSA -keysize 2048 -keystore keystore.jks -storepass changeit -dname "CN=Test, O=Example, C=SE" keytool -certreq -alias test -keystore keystore.jks -storepass changeit -file csr.p10
Verify REST API with testtools
To verify the REST API:
In the command prompt, start an interactive session, by typing the command:
Example: Generate REST API request
java –jar testtools.jar APIClient interactive
-
Run the following command to send the CSR to CM:
Example: Send CSR to CM
pkcs10-pkcs7 csr.p10
-
Save cert.cer.