New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

aws-pca

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-pca

A library to generate a certificate for HTTPS use using AWS Private Certificate Authority (PCA)

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

node-aws-pca

A library to generate and fetch a certificate for HTTPS use using AWS Private Certificate Authority (PCA).

Install

Required:

  • aws-sdk for calling AWS
  • pem for generating CSRs (Certificate Signing Requests)

npm i aws-pca pem aws-sdk

Usage

import AWS from 'aws-sdk'
import pem from 'pem'
import { PCA } from 'aws-pca'

export async function sample () {
  // See https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/ACMPCA.html#constructor-property
  // for possible options
  const acmpca = new AWS.ACMPCA()

  // The value of your CA (Certificate Authority) ARN in AWS PCA
  const CA_ARN = 'arn:aws:acm-pca:us-west-2:123456789012:certificate-authority/4819f73f-af7c-4abf-8753-62e40512cac6'

  const pca = new PCA(acmpca, pem, CA_ARN)

  // Create a CSR + client key which will be used to issue a certificate
  // See https://www.deineagentur.com/projects/pem/module-pem.html#.createCSR

  const csrData = await pca.createCSR({
    hash: 'sha256',
    country: 'US',
    state: 'California',
    locality: 'San Francisco',
    organization: 'Fake Company, Inc',
    organizationUnit: 'Engineering',
    commonName: 'fake.com',
    altNames: ['alt-fake.com']
  })

  // Create the server certificate
  // See https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/ACMPCA.html#issueCertificate-property
  // no need to specify CertificateAuthorityArn since you specified it in the constructor

  const issueData = await pca.issueCertificate(csrData.csr, {
    SigningAlgorithm: 'SHA256WITHRSA',
    Validity: {
      Type: 'YEARS',
      Value: 1
    }
  })

  // Get the server certificate
  // Note: You might have to wait a few seconds if you just issued the certificate
  // before you can fetch it as AWS PCA has not actually created it yet

  const certData = await pca.getCertificate(issueData.CertificateArn)

  // certData will have { Certificate, CertificateChain }

  // Get the CA certificate if you need to add it to your trust stores
  const caData = await pca.getCaCertificate()

  // caData will have { Certificate, CertificateChain }
}

Keywords

FAQs

Package last updated on 14 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc