Skip to content

Commit b5a372c

Browse files
committed
docs: adjust documentation
1 parent b64af0b commit b5a372c

1 file changed

Lines changed: 43 additions & 17 deletions

File tree

README.md

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
# https-pem
1+
# @metcoder95/https-pem
2+
3+
> This is a fork of the original [https-pem](https://github.com/watson/https-pem) package, modified to work with Node.js 24 and above.
24
35
Self-signed PEM key and certificate ready for use in your HTTPS server.
46

57
A dead simple way to get an HTTPS server running in development with no
68
need to generate the self signed PEM key and certificate.
79

8-
[![Build status](https://travis-ci.org/watson/https-pem.svg?branch=master)](https://travis-ci.org/watson/https-pem)
10+
[![CI](https://github.com/metcoder95/https-pem/actions/workflows/ci.yml/badge.svg)](https://github.com/metcoder95/https-pem/actions/workflows/ci.yml)
911
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)
1012

1113
## Installation
1214

1315
```
14-
npm install https-pem
16+
npm install @metcoder95/https-pem
1517
```
1618

1719
**Warning:** Upon installation a private key and a self signed
@@ -21,36 +23,38 @@ this secure in any way. I suggest only using this for testing and
2123
development where you just need an easy and quick way to run an HTTPS
2224
server with Node.js.
2325

26+
> **Note**: for Node.js 24 and above, the key size has been increased to 2048 bits due to changes in OpenSSL. For earlier versions, the default key size is used.
27+
2428
## Example Usage
2529

2630
```js
27-
var https = require('https')
28-
var pem = require('https-pem')
31+
const https = require('https');
32+
const pem = require('@metcoder95/https-pem');
2933

30-
var server = https.createServer(pem, function (req, res) {
31-
res.end('This is servered over HTTPS')
32-
})
34+
const server = https.createServer(pem, function (req, res) {
35+
res.end('This is servered over HTTPS');
36+
});
3337

3438
server.listen(443, function () {
35-
console.log('The server is running on https://localhost')
36-
})
39+
console.log('The server is running on https://localhost');
40+
});
3741
```
3842

3943
### Connecting
4044

4145
When connecting to an HTTPS server from Node.js that uses a self-signed
4246
certificate, `https.request` will normally emit an `error` and refuse to
43-
complete the reuqest. To get around that simply set the
47+
complete the request. To get around that simply set the
4448
`rejectUnauthorized` option to `false`:
4549

4650
```js
47-
var opts = { rejectUnauthorized: false }
51+
const opts = { rejectUnauthorized: false };
4852

49-
var req = https.request(opts, function (res) {
53+
const req = https.request(opts, function (res) {
5054
// ...
51-
})
55+
});
5256

53-
req.end()
57+
req.end();
5458
```
5559

5660
If using `curl` to connect to a Node.js HTTPS server using a
@@ -65,13 +69,35 @@ curl -k https://localhost:443
6569
The `https-pem` module simply exposes an object with two properties:
6670
`key` and `cert`.
6771

72+
### `pem.generate()`
73+
74+
Generates a new self-signed certificate and key pair.
75+
76+
```js
77+
const pem = require('@metcoder95/https-pem');
78+
pem.generate();
79+
```
80+
81+
#### Parameters
82+
83+
- `HttpPEMGeneratorOptions`: An object that can be passed to the `selfsigned.generate` method. This allows you to customize the generation of the key and certificate, such as setting the key size or adding custom attributes.
84+
- `attr`: (optional) An array of attributes to include in the certificate. See the [selfsigned](https://github.com/jfromaniello/selfsigned#attributes) documentation for more information.
85+
- `opts`: (optional) An object with options for the `selfsigned.generate` method. See the [selfsigned](https://github.com/jfromaniello/selfsigned#attributes) documentation for available options.
86+
- `done`: (optional) A callback function that will be called with the generated key and certificate. If not provided, the function will return a promise that resolves with the generated key and certificate.
87+
88+
#### Returns
89+
90+
- HttpsPEMGenerateResult: An object containing the generated key and certificate.
91+
- `key`: The generated private key in PEM format.
92+
- `cert`: The generated self-signed certificate in PEM format.
93+
6894
### `pem.key`
6995

70-
The private key (RSA).
96+
The autogenerated private key (RSA).
7197

7298
### `pem.cert`
7399

74-
The certificate.
100+
The autogenerated self-signed certificate.
75101

76102
## License
77103

0 commit comments

Comments
 (0)