-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Rodion93/develop
Initial commit
- Loading branch information
Showing
14 changed files
with
4,310 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"plugins": ["babel-plugin-rewire"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,3 +59,5 @@ typings/ | |
|
||
# next.js build output | ||
.next | ||
|
||
/.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules | ||
/.vscode |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
language: node_js | ||
node_js: | ||
- 10 | ||
branches: | ||
only: | ||
- master | ||
|
||
script: echo "Running tests against $(node -v)..." | ||
|
||
jobs: | ||
include: | ||
- stage: Produce Coverage | ||
node_js: node | ||
script: jest --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
win-cert | ||
====== | ||
|
||
[![Build Status](https://travis-ci.org/Rodion93/win-cert.svg?branch=master)](https://travis-ci.org/Rodion93/win-cert) [![Coverage Status](https://coveralls.io/repos/github/Rodion93/win-cert/badge.svg?branch=master)](https://coveralls.io/github/Rodion93/win-cert?branch=master) | ||
|
||
win-cert - Library for obtaining certificates from the Windows certificate store. | ||
|
||
ATTENTION - If you want to get one certificate, your certificate must be marked as exported | ||
and must be imported properly (the key must be stored in the right place), otherwise the method | ||
returns a certificate with an empty private key. | ||
|
||
Init | ||
=========== | ||
|
||
```bash | ||
npm install win-cert | ||
``` | ||
or | ||
```bash | ||
yarn add win-cert | ||
``` | ||
|
||
API | ||
=========== | ||
|
||
### getCertificate | ||
|
||
Returns certificate and private key in PEM format. | ||
Options are required; | ||
|
||
```javascript | ||
const winCert = require('win-cert'); | ||
|
||
... | ||
|
||
const options = { | ||
storeName: 'My', | ||
storeLocation: 'CurrentUser', | ||
thumbprint: '098d3.....' | ||
}; | ||
|
||
const certAndKey = await winCert.getCertificate(options); | ||
|
||
certAndKey.cert; | ||
certAndKey.key; | ||
|
||
``` | ||
|
||
### getAllCertificates | ||
|
||
Returns all certificates as objects. Options are not required. | ||
|
||
The returned object `certs` is a object like this: | ||
|
||
```json | ||
{ | ||
"subject": "CN=hello.com, O=Internet Widgits Pty Ltd, S=Some-State, C=AU", | ||
"issuer": "foo bar", | ||
"thumbprint": "...", | ||
"pem": "-----BEGIN CERTIFICATE-----\nMIID9DCCAtygAwIBAgIJANWBEUdUZOlPMA0GCSqGSIb3DQEBBQUAMFkxCzAJBgNV..." | ||
} | ||
``` | ||
|
||
```javascript | ||
const winCert = require('win-cert'); | ||
|
||
... | ||
|
||
const options = { | ||
storeName: 'My', | ||
storeLocation: 'CurrentUser' | ||
}; | ||
|
||
const certificates = await winCert.getAllCertificates(options); | ||
|
||
certificates.forEach(cert => { | ||
console.log(cert); | ||
}); | ||
|
||
``` | ||
|
||
Example application | ||
=========== | ||
|
||
```javascript | ||
const winCert = require('win-cert'); | ||
const express = require('express'); | ||
const https = require('https'); | ||
|
||
const main = async () => { | ||
const certAndKey = await winCert.getCertificate({ | ||
storeName: 'Root', | ||
storeLocation: 'LocalMachine', | ||
thumbprint: 'Your thumbprint' | ||
}); | ||
|
||
const options = { | ||
cert: certAndKey.cert, | ||
key: certAndKey.key, | ||
ca: certAndKey.cert, | ||
requestCert: true, | ||
rejectUnauthorized: false | ||
}; | ||
|
||
const app = express(); | ||
|
||
https | ||
.createServer(options, app) | ||
.listen(44331, () => console.log('Server started listening')); | ||
}; | ||
|
||
main(); | ||
``` | ||
|
||
or | ||
|
||
```javascript | ||
const winCert = require('win-cert'); | ||
|
||
const main = async () => { | ||
const allCerts = await winCert.getAllCertificates({ | ||
storeName: 'Root', | ||
storeLocation: 'CurrentUser' | ||
}); | ||
|
||
allCerts.forEach(cert => console.log(cert)); | ||
}; | ||
|
||
main(); | ||
``` | ||
|
||
License | ||
======= | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
module.exports = require('./src/winCert'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"name": "win-cert", | ||
"version": "0.1.0", | ||
"description": "Library for obtaining certificates from the Windows certificate store", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"keywords": [ | ||
"win", | ||
"certificate", | ||
"getCertificate", | ||
"win store", | ||
"X509", | ||
"pem" | ||
], | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "http://www.opensource.org/licenses/MIT" | ||
} | ||
], | ||
"author": { | ||
"name": "Rodion Horbulenko" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Rodion93/win-cert.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/Rodion93/win-cert/issues" | ||
}, | ||
"scripts": { | ||
"test": "jest" | ||
}, | ||
"engines": { | ||
"node": ">= 10.17.0" | ||
}, | ||
"files": [ | ||
"README.md", | ||
"index.js", | ||
"LICENSE" | ||
], | ||
"dependencies": { | ||
"edge-js": "^13.0.1" | ||
}, | ||
"devDependencies": { | ||
"babel-jest": "^24.9.0", | ||
"babel-plugin-rewire": "^1.2.0", | ||
"coveralls": "^3.0.7", | ||
"jest": "^24.9.0" | ||
} | ||
} |
Oops, something went wrong.