Compare commits

...

5 Commits

Author SHA1 Message Date
8211d9b6d8 node v6 bugfix: don't convert NodeBuffer to Uint8Array 2019-06-03 03:25:19 -06:00
361b0bf994 doc updates 2018-12-16 00:34:53 -07:00
c392b72120 proper link to new issue 2018-11-24 00:08:01 -07:00
f2a9fc083a markdown syntax fix 2018-11-23 23:59:32 -07:00
f68f5f8d0f add backlinks (for code and doc mirrors) 2018-11-23 23:46:03 -07:00
4 changed files with 17 additions and 15 deletions

View File

@ -1,8 +1,9 @@
RSA-CSR.js
[RSA-CSR.js](https://git.coolaj86.com/coolaj86/rsa-csr.js)
==========
Sponsored by [Root](https://therootcompany.com),
built for [ACME.js](https://git.coolaj86.com/coolaj86/acme.js)
A [Root](https://therootcompany.com) Project.
Built for [ACME.js](https://git.coolaj86.com/coolaj86/acme.js)
and [Greenlock.js](https://git.coolaj86.com/coolaj86/greenlock-express.js)
A focused, **zero-dependency** library that can do exactly one thing really, really well:
@ -10,10 +11,6 @@ A focused, **zero-dependency** library that can do exactly one thing really, rea
| < 300 lines of code | 1.7k gzipped | 4.7k minified | 8.5k with comments |
Need JWK-to-PEM? Try [Rasha.js](https://git.coolaj86.com/coolaj86/rasha.js)
Need to generate an EC CSR? Try [ECSDA-CSR.js](https://git.coolaj86.com/coolaj86/ecdsa-csr.js)
Features
========
@ -32,6 +29,10 @@ Features
* [x] Vanilla Node.js
* no school like the old school
* easy to read and understand
* [ ] JWK-to-PEM
* See [Rasha.js](https://git.coolaj86.com/coolaj86/rasha.js)
* [ ] EC CSR
* See [ECSDA-CSR.js](https://git.coolaj86.com/coolaj86/ecdsa-csr.js)
Usage
-----
@ -56,7 +57,7 @@ var key = {
};
var domains = [ 'example.com', 'www.example.com' ];
return rsacsr({ key: key, domains: domains }).then(function (csr) {
return rsacsr({ jwk: key, domains: domains }).then(function (csr) {
console.log('CSR PEM:');
console.log(csr);
});
@ -64,7 +65,7 @@ return rsacsr({ key: key, domains: domains }).then(function (csr) {
The output will look something like this (but much longer):
```js
```
-----BEGIN CERTIFICATE REQUEST-----
MIIClTCCAX0CAQAwFjEUMBIGA1UEAwwLZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3
DQEBAQUAA4IBDwAwggEKAoIBAQCba21UHE+VbDTpmYYFZUOV+OQ8AngOCdjROsPC
@ -81,7 +82,7 @@ If you need to convert a PEM to JWK first, do so:
```js
var Rasha = require('rasha');
Rasha.import({ pem: '-----BEGIN RSA PRIVATE KEY-----\nMIIEpAI..." }).then(function (jwk) {
Rasha.import({ pem: "-----BEGIN RSA PRIVATE KEY-----\nMIIEpAI..." }).then(function (jwk) {
console.log(jwk);
})
```
@ -171,7 +172,7 @@ Rather than trying to make a generic implementation that works with everything u
this library is intentionally focused on around the use case of generating certificates for
ACME services (such as Let's Encrypt).
That said, [please tell me](https://git.coolaj86.com/coolaj86/rsa-csr.js/issues) if it doesn't
That said, [please tell me](https://git.coolaj86.com/coolaj86/rsa-csr.js/issues/new) if it doesn't
do what you need, it may make sense to add it (or otherwise, perhaps to help you create a fork).
The primary goal of this project is for this code to do exactly (and all of)
@ -208,6 +209,7 @@ Hence, all of these projects are MPL-2.0 licensed.
Legal
-----
[RSA-CSR.js](https://git.coolaj86.com/coolaj86/rsa-csr.js) |
MPL-2.0 |
[Terms of Use](https://therootcompany.com/legal/#terms) |
[Privacy Policy](https://therootcompany.com/legal/#privacy)

View File

@ -15,7 +15,7 @@ try {
// ignore
}
rsacsr({ key: key, domains: domains }).then(function (csr) {
rsacsr({ jwk: key, domains: domains }).then(function (csr) {
// Using error so that we can redirect stdout to file
//console.error("CN=" + domains[0]);
//console.error("subjectAltName=" + domains.join(','));

View File

@ -110,13 +110,13 @@ RSA.sign = function signRsa(keypem, ab) {
return Promise.resolve().then(function () {
// Signer is a stream
var sign = crypto.createSign('SHA256');
sign.write(new Uint8Array(ab));
sign.write(ab);
sign.end();
// The signature is ASN1 encoded, as it turns out
var sig = sign.sign(keypem);
// Convert to a JavaScript ArrayBuffer just because
return new Uint8Array(sig.buffer.slice(sig.byteOffset, sig.byteOffset + sig.byteLength));
return sig.buffer.slice(sig.byteOffset, sig.byteOffset + sig.byteLength);
});
};

View File

@ -1,6 +1,6 @@
{
"name": "rsa-csr",
"version": "1.0.2",
"version": "1.0.6",
"description": "💯 A focused, zero-dependency library to generate a Certificate Signing Request (CSR) and sign it!",
"homepage": "https://git.coolaj86.com/coolaj86/rsa-csr.js",
"main": "index.js",