Giter Site home page Giter Site logo

keyvault-ca's Introduction

Some Context

Please refer to this blog post for details.

Overview

Getting Started

Clone this repo and then cd KeyVaultCA

Prerequisites

  1. Create Azure KeyVault:
    az keyvault create --name <KEYVAULT_NAME> \
    --resource-group keyvault-ca \
    --enable-soft-delete=true \
    --enable-purge-protection=true

Setup KeyVault access for the API façade

  1. Create a Service Principal in AAD
    az ad sp create-for-rbac --name api-facade-for-keyvault-ca --skip-assignment=true
    You will get an output containing appId and password, please note them for later.

  2. Give the Service Principal accesss to KeyVault keys and certificates:
    az keyvault set-policy --name <KEYVAULT_NAME> \
    --spn <your appId> \
    --key-permissions sign \
    --certificate-permissions get list update create

Generate a new Root CA in KeyVault

  1. Run the API Facade like this (feel free to use your own values for the subject):
    dotnet run --appId <YOUR_APPID> --secret <YOUR_APP_SECRET> \
    --ca --subject="C=US, ST=WA, L=Redmond, O=Contoso, OU=Contoso HR, CN=Contoso Inc" \
    --issuercert ContosoRootCA --kvName <KEYVAULT_NAME>

Request a new device certificate

  1. First generate the private key:
    openssl genrsa -out mydevice.key 2048

  2. Create the CSR:
    openssl req -new -key mydevice.key -out mydevice.csr
    openssl req -in mydevice.csr -out mydevice.csr.der -outform DER

  3. Run the API Facade and pass all required arguments:
    dotnet run --appId <YOUR_APPID> --secret <YOUR_APP_SECRET> \
    --issuercert ContosoRootCA --csrPath <PATH_TO_CSR_IN_DER_FORMAT> \
    --output <OUTPUT_CERTIFICATE_FILENAME> --kvName <KEYVAULT_NAME>

keyvault-ca's People

Contributors

vslepakov avatar

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.