Giter Club home page Giter Club logo

onprem-private-key's Introduction

Rollout On Premise Reference Implementation

Overview

Rollout's patching process for live native iOS apps involves downloading patches from the cloud to mobile devices. To ensure the authenticity of patches Rollout incorporates a security mechanism which is built upon asymmetric key pairs (private / public keys). Rollout's SDK is bundled with a certificate that contains a public key (which is extracted at runtime) to verify that the patch was signed with the corresponding private key.

For increased security, Rollout's on-premise signing service allows enterprise customers to use their own public/private key pair instead of Rollout's own keys. This means that only the client can sign patches before they are pushed to live devices. This also gives the client full control over the approval process of releasing a patch to live devices.

More about Rollout's security can be found here

This project provides a reference implementation for the on-premise signing service that a client needs to install / implement in order to support signing patches with their own keys. The service should create an HTTP endpoint, accessible by Rollout servers. Rollout servers will send request with payload and response URL. The service will sign the payload and send back the signature to the response URL. Signed responses are validated and released to devices.

Installation

Install node

Download Nodejs from https://nodejs.org/en/download/ and install on your machine.

Clone from git and install dependencies

Clone Rollout's sign service from the following git repository

  • $ git clone https://github.com/rollout/onprem-private-key-reference-implementation.git
  • $ cd onprem-private-key-reference-implementation
  • $ npm install to install all dependecies

Quick start

Start the signer service:

npm start

Verify the service responds by sending sign request to the service

node rollout/simulate_rollout_signing_request.js http://localhost:4000/rollout/sign ./keys/535110d5fb598c7a01635d108ab69e54/certificate.cert

OR

npm run simulate

The command creates sample Rollout configuration which is sent to a signing url with the given certificate. You can use it with different signing service implementation by replacing the url and the certificate arguments. Make sure to run this script only after the remote signining service is up and running.

Test the signer service implementation

Run intergration tests (uses mocha)

npm test

More on the Sign Service

The signer service will recieve the following JSON to be POSTed to /rollout/sign HTTP endpoint (the request is sent by Rollout servers)

{
  "data": "", // The data to be signed by the service, it is a stringified JSON
  "certificateMd5": "535110d5fb598c7a01635d108ab69e54", // `md5` value generated of the certificate registered via Rollout dashboard. Ususally act as a key to the private key in a local map.
  "responseURL": "https://app.rollout.io/api/app-versions/:appId/signing_data/:transactionId" // The url which you should send the result too.
}

After receiving the request, the signer:

  1. Verifies the incoming certificate md5 points to existing key (reply with error if not)
  2. Sign the payload on data with the private key that matches md5 of the certificate in the request
  3. Send response with the signed data by POSTing to the responseURL given in the request

Creating and installing new private keys

Installing new private keys

The reference implementation of the signer service looks for the private keys in the directory keys. The directory should contain a subdirectory which name is md5 of the certificate associated with the private key. See example in the project structure.

Creating new private key and certificate

Run the bash commands to create certificate and private key pairs using openssl. Place them in the right directory structure using md5 command (available on mac)

On Mac

  1. Create /tmp/certificate.cert and /tmp/private.pem by running
openssl req  -nodes -new -x509  -keyout /tmp/private.pem -out /tmp/certificate.cert
  1. Answer the questions on the command prompt for generating the certificate.
  2. Save md5 in a variable, by running
certificate_md5=$(cat /tmp/certificate.cert | grep -v -- '-----BEGIN CERTIFICATE-----'  | grep -v -- '-----END CERTIFICATE-----' | tr -d '\n'| md5)
echo $certificate_md5
  1. Create the <project_dir>/keys/<md5> folder
mkdir ./keys/$certificate_md5
  1. Move certificate and private key into <project_dir>/keys/<certificate_md5> folder
mv /tmp/private.pem /tmp/certificate.cert ./keys/$certificate_md5/

On Linux

  1. Create /tmp/certificate.cert and /tmp/private.pem by running:
openssl req  -nodes -new -x509  -keyout /tmp/private.pem -out /tmp/certificate.cert
  1. Answer the questions on the command prompt for generating the certificate.

  2. Save md5 in a variable, by running:

certificate_md5=$(cat /tmp/certificate.cert | grep -v -- '-----BEGIN CERTIFICATE-----'  | grep -v -- '-----END CERTIFICATE-----' | tr -d '\n'|  md5sum  | awk '{print $1}')
echo $certificate_md5
  1. Create the <project_dir>/keys/<md5> folder
mkdir ./keys/$certificate_md5
  1. Move certificate and private key into <project_dir>/keys/<certificate_md5> folder
mv /tmp/private.pem /tmp/certificate.cert ./keys/$certificate_md5/

When complete you should have private key in private.pem and certificate ready in certificate.cert

onprem-private-key's People

Contributors

prutwo avatar

Watchers

Jorge (Hezi) Cohen avatar James Cloos avatar Andrew Goldis avatar Eyal Keren avatar Kfir Erez avatar Dimitris Armenatzoglou avatar  avatar Mark Wynn-Mackenzie avatar

onprem-private-key's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.