Skip to main content

Register Public Key

;TLDR

  1. Download script generate.sh
  2. Run script generate public_key.pub private_key.pem
  3. Upload via API using Postman

Guide

Before starting encryption development, Partners should have their own pair of private key and public key. Partners could generate their keys using openssl as our toolkit for encryption, please download install this toolkit if you didn't have it yet. Make sure the version is 1.1.1 or newer. You can check using this command:

> openssl version
OpenSSL 1.1.1 11 Sep 2018

You can refer for full documentation here. Specifically for generating the RSA private key you can use this command:

openssl genrsa -out <generated_private_key_file> 2048

The partner should save this private key securely and never reveal to any other party. If necessary, you can generate new private key and re-submit the new public key to OpenAPI again.

For generating public key you can use this command:

openssl rsa -in <private_key_file> -pubout -out <generated_public _key_file>

This generated public key file will be submited to OpenAPI that will be use for use when encrypting the data when being sent to partner side. When partner submit this public key, it means partner ready to start their development for encryption implementation.

For other alternative, you can use our downloaded script to generate your public key and private key. You can download the script here. Then you can run the script using this command (use sudo if necessary):

chmod +x generate.sh
./generate.sh <public_key> <private_key>

Submit Public Key

After generating private key and public key, you can upload your public key to API using postman. For another improvement we will provide proper public key management in Developer Console.

The next step you can start to learn about Creating Request Signature and How to Decrypt Message.

Register Public Key using API

If you want to upload or update public key yourself you can use this endpoint below

post

/v1/fs/:fs_id/register?upload=1

With the following parameters:

ParameterTypeRequiredLocationDescription
fs_id
integer
required
path
Fulfillment service id.
upload
integer
required
query
When upload, value should be 1
public_key
file
required
form data
Attached Public Key using multipart/form-data

Example request

This example can't be constructed manually without Postman or any kind of application that support upload multipart form data file.

curl -X POST \
'https://fs.tokopedia.net/v1/fs/13398/register?upload=1' \
-H 'Authorization: Bearer JhgtdgUAQ5OJIrQMJjCiHA'
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
-F public_key=@/home/nakama/testcase/public.txt
  • Guide
  • Submit Public Key
  • Register Public Key using API
  • Have a feedback?