Git Product home page Git Product logo

kes-certificate-generator's Introduction

kes-certificate-generator

Self-signed certificate generation for MinIO KES

KES is a stateless and distributed key-management system for high-performance applications. We built KES as the bridge between modern applications - running as containers on Kubernetes - and centralized KMS solutions. Therefore, KES has been designed to be simple, scalable, and secure by default. It has just a few knobs to tweak instead of a complex configuration and does not require a deep understanding of secure key management or cryptography. More details about KES can be found here: https://blog.min.io/introducing-kes/

Generating certificates

Minimal code example for generating root and client certificates for MinIO KES server. The example below will generate a set of the certificates with a validity of one year:

import dayjs from 'dayjs';
import CertUtils from '@/certUtils';

import fs from 'fs-extra';
import path from 'path';

const pathToCertificates = path.join(__dirname, '../kes/cert/');
fs.ensureDirSync(pathToCertificates);

const ca = CertUtils.createRootCA(dayjs().add(1, 'y').toDate());

const privateCert = CertUtils.createHostCert(new Date(), 'localhost', [
    'localhost',
    '127.0.0.1'
], ca);

fs.writeFileSync(path.join(pathToCertificates, 'root.crt'), ca.certificate.toString());
fs.writeFileSync(path.join(pathToCertificates, 'root.key'), ca.privateKey.toString());

fs.writeFileSync(path.join(pathToCertificates, 'client.crt'), privateCert.certificate.toString());
fs.writeFileSync(path.join(pathToCertificates, 'client.key'), privateCert.privateKey.toString());

Once certificates are generated, you need to enlist root certificate and its key under tls section of the KES configuration file:

tls:
  key: /etc/kes/cert/root.key
  cert: /etc/kes/cert/root.crt

Checking certificate validity with OpenSSL

To test the root certificate validity with OpenSSL, execute the following:

openssl x509 -noout -in /etc/kes/cert/root.crt -enddate

Or for the client certificate:

openssl x509 -noout -in /etc/kes/cert/client.crt -enddate

Check certificate alt names

openssl x509 -noout -text -in /etc/kes/cert/client.crt | grep DNS | xargs

Getting certificate identity

Once the certificates are created, you need to enlist the client certificate identity in the KES server config file; you can find the configuration example at this repo in kes/config/config.yml. To get the certificate identity, run this command:

kes identity of /etc/kes/cert/client.crt

An example:

policy:
  my-app:
    allow:
      - /v1/key/*/*
    identities:
      - 59b25f1b844225b56a2b2fa4f3e6d6c218ee8204201dbf1e535ff32dab9fd300

Running KES server with custom configuration

In order to run KES server with your custom configuration with the new self-signed certificates you've created, you can run the following command:

kes server --config /etc/kes/config/config.yml --auth off

In case if you are running KES server in Docker, you can use the following docker-compose.yml file:

version: "3.9"

services:
  kes-server:
    container_name: kes-dev
    image: "minio/kes"
    ports:
      - "7373:7373"
    volumes:
      - ./cert/:/etc/kes/cert
      - ./config/:/etc/kes/config
    command: "server --config /etc/kes/config/config.yml --auth off"

Testing client certificates

To test the certificate, for example to list all the keys on KES server:

export KES_SERVER=https://localhost:7373
export KES_CLIENT_KEY=/etc/kes/cert/client.key
export KES_CLIENT_CERT=/etc/kes/cert/client.crt

curl -sSL --tlsv1.3 -k --key /etc/kes/cert/client.key --cert /etc/kes/cert/client.crt -X GET 'https://localhost:7373/v1/key/list/*'

#or with kes CLI:

kes key ls -k

kes-certificate-generator's People

Contributors

dependabot[bot] avatar renovate[bot] avatar skitsanos avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

kes-certificate-generator's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

docker-compose
kes/docker-compose.yml
github-actions
.github/workflows/dependabot-automerge.yml
  • dependabot/fetch-metadata v2.2.0
npm
package.json
  • dayjs ^1.11.9
  • fs-extra ^11.1.1
  • global ^4.4.0
  • node-forge ^1.3.1
  • npm-check-updates ^16.13.3
  • @types/fs-extra ^11.0.1
  • @types/node-forge ^1.3.4
  • ts-node ^10.9.1
  • tsconfig-paths ^4.2.0
  • typescript ^5.2.2

  • Check this box to trigger a request for Renovate to run again on this repository

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.