Skip to content

Instantly share code, notes, and snippets.

@rmagnum2002
rmagnum2002 / pkcs10Generator.js
Created July 17, 2022 03:28 — forked from tcd93/pkcs10Generator.js
Simple way to generate certificate signing request (CSR) with X.509 using Javascript
import * as asn1js from 'asn1js';
import { getCrypto, getAlgorithmParameters, CertificationRequest, AttributeTypeAndValue } from 'pkijs/build'
import { arrayBufferToString, toBase64 } from 'pvutils';
//https://github.com/PeculiarVentures/PKI.js/blob/31c10e9bb879cac59d710102adf4fd7bd61cd66c/src/CryptoEngine.js#L1300
const hashAlg = 'SHA-256'
const signAlg = 'ECDSA'
/**
* @example
* createPKCS10({ enrollmentID: 'user1', organizationUnit: 'Marketing', organization: 'Farmer Market', state: 'M', country: 'V' })