document csr generation
This commit is contained in:
parent
c24a7ab922
commit
d84d8ce94c
26
README.md
26
README.md
|
@ -5,6 +5,8 @@ JavaScript RSA utils that work on Windows, Mac, and Linux with or without C comp
|
|||
In order to provide a module that "just works" everywhere, we mix and match methods
|
||||
from `node.js` core, `ursa`, `forge`, and others.
|
||||
|
||||
This is useful for **certbot** and **letsencrypt**.
|
||||
|
||||
(in the future we'd like to provide the same API to the browser)
|
||||
|
||||
Examples
|
||||
|
@ -68,6 +70,8 @@ API
|
|||
* `RSA.exportPrivateJwk(keypair)`
|
||||
* `RSA.exportPublicJwk(keypair)`
|
||||
* `RSA.signJws(keypair, payload, nonce)`
|
||||
* `RSA.generateCsrPem(keypair, names)`
|
||||
* `RSA.generateCsrDerWeb64(keypair, names)`
|
||||
|
||||
`keypair` can be any object with any of these keys `publicKeyPem, privateKeyPem, publicKeyJwk, privateKeyJwk`
|
||||
|
||||
|
@ -118,7 +122,7 @@ console.log(keypair);
|
|||
|
||||
### RSA.signJws(keypair, payload, nonce)
|
||||
|
||||
Generates a signature in JWS format.
|
||||
Generates a signature in JWS format (necessary for **certbot**/**letsencrypt**).
|
||||
|
||||
```javascript
|
||||
var message = "Hello, World!"
|
||||
|
@ -144,3 +148,23 @@ The result looks like this:
|
|||
"signature": "Wb2al5SDyh5gjmkV79MK9m3sfNBBPjntSKor-34BBoGwr6n8qEnBmqB1Y4zbo-5rmvsoPmJsnRlP_hRiUY86zSAQyfbisTGrGBl0IQ7ditpkfYVm0rBWJ8WnYNqYNp8K3qcD7NW72tsy-XoWEjNlz4lWJeRdEG2Nt4CJgnREH4Y"
|
||||
}
|
||||
```
|
||||
|
||||
### RSA.generateCsr*(keypair, names)
|
||||
|
||||
You can generate the CSR in human-readable or binary / base64 formats:
|
||||
|
||||
`RSA.generateCsrPem(keypair, names)`:
|
||||
```javascript
|
||||
var pem = RSA.generateCsrPem(keypair, [ 'example.com', 'www.example.com' ]);
|
||||
|
||||
console.log(pem);
|
||||
```
|
||||
|
||||
web-safe base64 for **certbot**/**letsencrypt**:
|
||||
|
||||
`RSA.generateCsrDerWeb64(keypair, names)`:
|
||||
```javascript
|
||||
var web64 = RSA.generateCsrDerWeb64(keypair, [ 'example.com', 'www.example.com' ]);
|
||||
|
||||
console.log(web64);
|
||||
```
|
||||
|
|
2
node.js
2
node.js
|
@ -208,7 +208,7 @@ function create(deps) {
|
|||
|
||||
return RSA.utils._forgeBytesToBuf(der);
|
||||
};
|
||||
RSA.generateCsrWeb64 = function (keypair, names) {
|
||||
RSA.generateCsrDerWeb64 =RSA.generateCsrWeb64 = function (keypair, names) {
|
||||
var buf = RSA.generateCsrDer(keypair, names);
|
||||
var b64 = buf.toString('base64');
|
||||
var web64 = RSA.utils.toWebsafeBase64(b64);
|
||||
|
|
|
@ -17,7 +17,7 @@ var keypair = {
|
|||
};
|
||||
|
||||
var csrPem = RSA.generateCsrPem(keypair, ['example.com', 'www.example.com']);
|
||||
var csr64 = RSA.generateCsrWeb64(keypair, ['example.com', 'www.example.com']);
|
||||
var csr64 = RSA.generateCsrDerWeb64(keypair, ['example.com', 'www.example.com']);
|
||||
console.log('');
|
||||
console.log('DEBUG csrPem');
|
||||
console.log(csrPem);
|
||||
|
|
Loading…
Reference in New Issue