Gathering detailed insights and metrics for acme-client
Gathering detailed insights and metrics for acme-client
Gathering detailed insights and metrics for acme-client
Gathering detailed insights and metrics for acme-client
npm install acme-client
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
272 Stars
306 Commits
55 Forks
17 Watching
7 Branches
8 Contributors
Updated on 01 Nov 2024
Minified
Minified + Gzipped
JavaScript (98.92%)
TypeScript (1.08%)
Cumulative downloads
Total Downloads
Last day
54.5%
103,026
Compared to previous day
Last week
18.2%
435,064
Compared to previous week
Last month
9.1%
1,481,179
Compared to previous month
Last year
475.1%
4,793,958
Compared to previous year
A simple and unopinionated ACME client.
This module is written to handle communication with a Boulder/Let's Encrypt-style ACME API.
acme-client | Node.js | |
---|---|---|
v5.x | >= v16 | Upgrade guide |
v4.x | >= v10 | Changelog |
v3.x | >= v8 | Changelog |
v2.x | >= v4 | Changelog |
v1.x | >= v4 | Changelog |
1$ npm install acme-client
1const acme = require('acme-client'); 2 3const accountPrivateKey = '<PEM encoded private key>'; 4 5const client = new acme.Client({ 6 directoryUrl: acme.directory.letsencrypt.staging, 7 accountKey: accountPrivateKey, 8});
1acme.directory.buypass.staging; 2acme.directory.buypass.production; 3 4acme.directory.google.staging; 5acme.directory.google.production; 6 7acme.directory.letsencrypt.staging; 8acme.directory.letsencrypt.production; 9 10acme.directory.zerossl.production;
To enable external account binding when creating your ACME account, provide your KID and HMAC key to the client constructor.
1const client = new acme.Client({
2 directoryUrl: 'https://acme-provider.example.com/directory-url',
3 accountKey: accountPrivateKey,
4 externalAccountBinding: {
5 kid: 'YOUR-EAB-KID',
6 hmacKey: 'YOUR-EAB-HMAC-KEY',
7 },
8});
During the ACME account creation process, the server will check the supplied account key and either create a new account if the key is unused, or return the existing ACME account bound to that key.
In some cases, for example with some EAB providers, this account creation step may be prohibited and might require you to manually specify the account URL beforehand. This can be done through accountUrl
in the client constructor.
1const client = new acme.Client({
2 directoryUrl: acme.directory.letsencrypt.staging,
3 accountKey: accountPrivateKey,
4 accountUrl: 'https://acme-v02.api.letsencrypt.org/acme/acct/12345678',
5});
You can fetch the clients current account URL, either after creating an account or supplying it through the constructor, using getAccountUrl()
:
1const myAccountUrl = client.getAccountUrl();
For key pairs acme-client
utilizes native Node.js cryptography APIs, supporting signing and generation of both RSA and ECDSA keys. The module @peculiar/x509 is used to generate and parse Certificate Signing Requests.
These utility methods are exposed through .crypto
.
1const privateRsaKey = await acme.crypto.createPrivateRsaKey(); 2const privateEcdsaKey = await acme.crypto.createPrivateEcdsaKey(); 3 4const [certificateKey, certificateCsr] = await acme.crypto.createCsr({ 5 altNames: ['example.com', '*.example.com'], 6});
.forge
interfaceThe legacy node-forge
crypto interface is still available for backward compatibility, however this interface is now considered deprecated and will be removed in a future major version of acme-client
.
You should consider migrating to the new .crypto
API at your earliest convenience. More details can be found in the acme-client v5 upgrade guide.
For convenience an auto()
method is included in the client that takes a single config object. This method will handle the entire process of getting a certificate for one or multiple domains.
1const autoOpts = { 2 csr: '<PEM encoded CSR>', 3 email: 'test@example.com', 4 termsOfServiceAgreed: true, 5 challengeCreateFn: async (authz, challenge, keyAuthorization) => {}, 6 challengeRemoveFn: async (authz, challenge, keyAuthorization) => {}, 7}; 8 9const certificate = await client.auto(autoOpts);
When ordering a certificate using auto mode, acme-client
uses a priority list when selecting challenges to respond to. Its default value is ['http-01', 'dns-01']
which translates to "use http-01
if any challenges exist, otherwise fall back to dns-01
".
While most challenges can be validated using the method of your choosing, please note that wildcard certificates can only be validated through dns-01
. More information regarding Let's Encrypt challenge types can be found here.
To modify challenge priority, provide a list of challenge types in challengePriority
:
1await client.auto({ 2 ..., 3 challengePriority: ['http-01', 'dns-01'], 4});
When using auto mode, acme-client
will first validate that challenges are satisfied internally before completing the challenge at the ACME provider. In some cases (firewalls, etc) this internal challenge verification might not be possible to complete.
If internal challenge validation needs to travel through an HTTP proxy, see HTTP client defaults.
To completely disable acme-client
s internal challenge verification, enable skipChallengeVerification
:
1await client.auto({ 2 ..., 3 skipChallengeVerification: true, 4});
For more fine-grained control you can interact with the ACME API using the methods documented below.
1const account = await client.createAccount({
2 termsOfServiceAgreed: true,
3 contact: ['mailto:test@example.com'],
4});
5
6const order = await client.createOrder({
7 identifiers: [
8 { type: 'dns', value: 'example.com' },
9 { type: 'dns', value: '*.example.com' },
10 ],
11});
This module uses axios when communicating with the ACME HTTP API, and exposes the client instance through .axios
.
For example, should you need to change the default axios configuration to route requests through an HTTP proxy, this can be achieved as follows:
1const acme = require('acme-client'); 2 3acme.axios.defaults.proxy = { 4 host: '127.0.0.1', 5 port: 9000, 6};
A complete list of axios options and documentation can be found at:
To get a better grasp of what acme-client
is doing behind the scenes, you can either pass it a logger function, or enable debugging through an environment variable.
Setting a logger function may for example be useful for passing messages on to another logging system, or just dumping them to the console.
1acme.setLogger((message) => { 2 console.log(message); 3});
Debugging to the console can also be enabled through debug by setting an environment variable.
1DEBUG=acme-client node index.js
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More