Public Key Infrastructure (PKI) Implementation
Public Key Infrastructure (PKI) Explained
Public Key Infrastructure, or PKI, is a system that uses digital certificates to verify and authenticate the identity of users, devices, and services on the internet or private networks. It's a crucial technology for ensuring secure communication and data protection.
What is PKI?
PKI is a set of roles, policies, procedures, and systems needed to create, manage, distribute, use, store, and revoke digital certificates and manage public-key encryption. It provides a way to establish trust in online interactions. Ledger Enterprise is implementing PKI in its infrastructure so that a number of its critical READ or GET endpoints can share information securely.
Key Components
Digital Certificates
Digital certificates are electronic documents that bind a public key with an issuer identity over a given validity period.
Public and Private Keys
PKI uses asymmetric cryptography, which involves a pair of keys:
Public Key: Shared openly and used to encrypt data or verify digital signatures.
Private Key: Kept secret and used to decrypt data encrypted with the corresponding public key or to create digital signatures.
Certificate Authority (CA)
A CA is a trusted entity that issues digital certificates. It verifies the identity of the entity requesting the certificate and signs the certificate with its own private key, creating a chain of trust.
How PKI Works at Ledger Enterprise - Getting the Root CA
The process typically involves the following steps:
Certificate Request: Sign into the Ledger Vault as an administrator. In the settings section of the Vault, there will be a button that allows the administrator to reveal the Root Certificate Authority (Root CA) of the HSM.
Reveal the Certificate: The administrator will click this button and be taken through a flow that allows them to download the Root CA and save the User ID of the workspace. An example of the Root Certificate can be seen below. The file format will be either .der or .pem.
Compute the SHA-256: Once the certificate is saved, the administrator will need to use it to compute the SHA-256 from the certificate. This will then be used for verification.
To compute the SHA-256 on a Ubuntu or Mac, in the terminal, navigate to the directory the file is saved in and use the command
$ sha256sum root.der
. The output should be a 63 character aplpha-numeric string.
Certificate Verification: Once revealed, the administrator will then verify the SHA-256 as well as the User ID of the workspace on their Personal Security Device (PSD). If the information matches the previously saved information, it is safe and can be used for future verification.
Using the Certificate: When receiving address information from Ledger, the client will then be able to use this Root CA to verify the signed information that is sent from the relevant GET requests. This is further explained in the following section.
Example certificate
Using the Root CA
Now that the Root CA has been verified on the PSD and downloaded, we need to use it to verify the certificate chain so that we can trust the information we receive. Do this with the following steps:
Retrieve Certificate Chain: Using your API Operator, we will have a certificate chain endpoint that allows you to verify incoming information.
The certificate chain will be retrieved by an API endpoint - GET /pki/certificate-chain
The first certificate is signed by the RootCA. The second certificate is signed by the first certificate and so on, creating a chain of trust.
This is workspace specific, so if your organisation has more than one workspace, this will need to be implemented on a per workspace level.
Verify the Certificate Chain: Using the SHA-256 and the User ID from previous steps, locally verify that the certificate chain. The chain of trust will then be secured as follows:
PSD is trusted thanks to end to end authentication with the HSM
This means that the Root CA that has been verified with the PSD can be trusted.
This means that the calculated SHA-256 can be trusted.
Which means that the Certificate Chain can be trusted down to the leaf.
Using this, API data can be trusted.
READ or GET information: Each time you request information requiring HSM data, it will be signed by the JWS of the leaf certificate of the chain you retrieved above.
Use information: This information has now been verified and you can use it in the ways you see fit.
Impacted Endpoints
We are introducing two new endpoints that will allow clients to GET address based data in a secure manner. They will look very similar to previous endpoints that were used to retrieve addresses, but will now be updated to include PKI specific data.
Endpoint 1 - Get an address at a specific index:
This would allow a client to get a specific address of a UTXO based account.
By default, you will get Receive address here and not change address. As both could be useful for audit purposes, we will also add a query parameter: ?address_type=receive|change.
NB: The response will only be the JWT token, but below we provide an example of the details that will be masked by the JWT token.
Endpoint 2 - Get an address for non-UTXO based account:
Here, using a specific index does not make sense when retrieving account address, so the endpoint and response would look as follows:
NB: The response will only be the JWT token, but below we provide an example of the details that will be masked by the JWT token.
Last updated