Code Monkey home page Code Monkey logo

awscrtsign's Introduction

awsCrtSign

This program, awsCrtSign, retrieves key material from an AWS KMS RSA Signing Key. It uses this key material to construct a self-signed X.509v3 certificate.

Why is this useful? Some services like SalesForce use OAuth Bearer tokens to authenticate to their API via a JSON Web Token (JWT) and require an X.509 certificate to configure their Web App's endpoint. I wanted to use AWS Lambda to access one of these web applications while keeping my key material safe. I therefore wanted to put all my key material into a secure key management environment: AWS KMS. But I still needed the corresponding X.509 certificate.

AWS KMS will sign things for you at $1/month for a key and 3 cents/10,000 API calls/signatures (at time of writing). Yes, $12/year is a huge and difficult to justify cost but a Serverless env in my case made this cost efficient.

AWS lets you get the public key material of an asymmetric RSA Key via the AWS KMS API but not an X509 certificate. You can get AWS to sign a Digest. An X.509 certificate however is essentially only these two things combined with some metadata. That's where this program comes in.

awsCrtSign

Retrieves key material from an Amazon KMS RSA Signing Key. It uses this key material to construct a selfsigned X.509 certificate.

Usage:

awsCrtSign -arn AWS_key_id -CN "commonName" -ST "stateOrProvince" -O "Organisation" -C "Country" -email emailAddress -years years

AWS_key_id

is the full ARN of the AWS Key you wish to use e.g. arn:aws:kms:eu-west-1:012345678901:key/12345678-9abc-def0-1234-56789abcdef0

commonName

is the Common Name to be used in the certifiate's subject and issuer field. e.g. Robot Certificate 1. It must be an X.500 printableString.

stateOrProvince

is the stateOrProvince used in the certifiate's subject and issuer field. e.g. Manchester. It must be an X.500 printableString.

Organisation

is the Organisation used in the certifiate's subject and issuer field. e.g. ACME Certificates Inc. It must be an X.500 printableString.

Country

is the Country name to be used in the certifiate's subject and issuer field. e.g. GB. It should be an ISO 3166-1 alpha-2 country code. It must be a string of two X.500 printableString characters.

emailAddress (optional)

is the email address you want in the Issuer Alt Name field. e.g. [email protected]. It must be an RFC822 emailAddress. This is optional with no default.

years (optional)

is the length of time the certificate will be valid for. Default 10. It can be any positive integer as long as "now + years years" works with the date command. The expiry date will be encoded as a UTCTIME string i.e. YYMMDDHHMMSSZ so choose wisely!

The certificate will be self-signed and have a Distinguished name of the form:

/C=<Country>/ST=<stateOrProvince>/L=<AWS Zone e.g. eu-west-1>/O=<Organisation>/CN=<commonName>

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.