mirror of
https://github.com/NationalSecurityAgency/MADCert.git
synced 2026-11-09 04:09:56 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
531be027f5 | ||
|
|
3deb4ccf9f | ||
|
|
b44c79c3af | ||
|
|
39dbf747e6 | ||
|
|
663bb10e0b | ||
|
|
0c30721bca | ||
|
|
5c976801fb | ||
|
|
e7f88431c6 | ||
|
|
f8e3721210 | ||
|
|
e8deada753 | ||
|
|
a21293fe94 | ||
|
|
b9067f2342 |
No files matched your search
@@ -6,7 +6,7 @@ MADCert is a cross-platform tool that consists of a certificate generator, a fil
|
||||
|
||||
MADCert does not require openssl or any other programs to be installed in the Operating System.
|
||||
|
||||
Both Node.js and CLI exmples are provided below.
|
||||
Both Node.js and CLI examples are provided below.
|
||||
|
||||
|
||||
## Usage
|
||||
@@ -49,7 +49,7 @@ To add MADCert to your project:
|
||||
|
||||
madcert.listCACerts();
|
||||
|
||||
- List Server Cerficates
|
||||
- List Server Certificates
|
||||
|
||||
madcert.listServerCerts();
|
||||
|
||||
@@ -146,7 +146,7 @@ By default, the certs created by MADCert will be placed under a "pki" folder in
|
||||
|
||||
npx madcert ca-list
|
||||
|
||||
- List Server Cerficates
|
||||
- List Server Certificates
|
||||
|
||||
npx madcert server-list
|
||||
|
||||
@@ -190,6 +190,23 @@ By default, the certs created by MADCert will be placed under a "pki" folder in
|
||||
|
||||
#### Arguments
|
||||
|
||||
- `name` Name is used for the name of the directory under which PKI files are created. If the `--common-name` option is not used then `name` will also be used for the Common Name in the certificate subject.
|
||||
- `ca_name` CA name is used to identify the Certificate Authority to use when creating or removing users and servers.
|
||||
- `root_ca_name` When creating an intermediate Certificate Authority, `root_ca_name` identifies the root CA that issues the intermediate CA's certificate.
|
||||
|
||||
| | Alias | Type | Default Value | Description |
|
||||
| :--- | :----:| :----: | :----: | ---: |
|
||||
| `name` | | String | | Name is used for the name of the directory under which PKI files are created. If the `--common-name` option is not used then `name` will also be used for the Common Name in the certificate subject. |
|
||||
| `ca-name` | | String | | CA name is used to identify the Certificate Authority to use when creating or removing users and servers. |
|
||||
| `root_ca-name` | `-r` | String | | When creating an intermediate Certificate Authority, `root_ca_name` identifies the root CA that issues the intermediate CA's certificate.
|
||||
| `path` | `-p` | String | '/pki' | Base path for pki |
|
||||
| `common-name` | `-n` | String | | Common Name in the Distinguished Name |
|
||||
| `country` | `-c` | String | | Country |
|
||||
| `locality` | | String | | Locality|
|
||||
| `state` | `-st` | String | | State|
|
||||
| `expired` | `-e` | Boolean | | Create an expired certificate |
|
||||
| `org` | `-o` | Array | | Organization name. This option can be specified multiple times|
|
||||
| `org-unit` | `-u` | Array | | Organizational unit name. This option can be specified multiple times.|
|
||||
| `password` | `-w` | String | 'changeme' | Certificate password |
|
||||
| `subject-alt-dns` | `-d` | Array | | Create certificate with DNS subject alternative name. This option can be specified multiple times and only applies to server certs.|
|
||||
| `subject-alt-ip` | `-i` | Array | | Create certificate with IP subject alternative name. This option can be specified multiple times and only applies to server certs. |
|
||||
| `subject-alt-email`| `-m` | Array | | Create certificate with rfc822/email subject alternative name. This option can be specified multiple times and only applies to server certs. |
|
||||
| `valid-from` | `-f` | Date | | Valid from date in ISO 8601 format |
|
||||
| `valid-to` | `-t` | Date | | Valid to date in ISO 8601 format|
|
||||
Generated
+9
-9
@@ -1,18 +1,18 @@
|
||||
{
|
||||
"name": "madcert",
|
||||
"version": "2.2.1",
|
||||
"version": "2.5.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "madcert",
|
||||
"version": "2.2.1",
|
||||
"version": "2.5.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"date-fns": "^2.19.0",
|
||||
"fs-extra": "10.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"node-forge": "^1.0.0",
|
||||
"node-forge": "^1.3.0",
|
||||
"yargs": "17.3.1"
|
||||
},
|
||||
"bin": {
|
||||
@@ -744,9 +744,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/node-forge": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.2.1.tgz",
|
||||
"integrity": "sha512-Fcvtbb+zBcZXbTTVwqGA5W+MKBj56UjVRevvchv5XrcyXbmNdesfZL37nlcWOfpgHhgmxApw3tQbTr4CqNmX4w==",
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.0.tgz",
|
||||
"integrity": "sha512-08ARB91bUi6zNKzVmaj3QO7cr397uiDT2nJ63cHjyNtCTWIgvS47j3eT0WfzUwS9+6Z5YshRaoasFkXCKrIYbA==",
|
||||
"engines": {
|
||||
"node": ">= 6.13.0"
|
||||
}
|
||||
@@ -1636,9 +1636,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node-forge": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.2.1.tgz",
|
||||
"integrity": "sha512-Fcvtbb+zBcZXbTTVwqGA5W+MKBj56UjVRevvchv5XrcyXbmNdesfZL37nlcWOfpgHhgmxApw3tQbTr4CqNmX4w=="
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.0.tgz",
|
||||
"integrity": "sha512-08ARB91bUi6zNKzVmaj3QO7cr397uiDT2nJ63cHjyNtCTWIgvS47j3eT0WfzUwS9+6Z5YshRaoasFkXCKrIYbA=="
|
||||
},
|
||||
"normalize-path": {
|
||||
"version": "3.0.0",
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "madcert",
|
||||
"version": "2.3.0",
|
||||
"version": "2.5.0",
|
||||
"description": "Make a Development Cert",
|
||||
"engines": {
|
||||
"node": ">=10.16.0"
|
||||
@@ -55,7 +55,7 @@
|
||||
"date-fns": "^2.19.0",
|
||||
"fs-extra": "10.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"node-forge": "^1.0.0",
|
||||
"node-forge": "^1.3.0",
|
||||
"yargs": "17.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -44,6 +44,9 @@ function buildCACert(keys, options, caCert = null) {
|
||||
digitalSignature: true,
|
||||
critical: true,
|
||||
cRLSign: true,
|
||||
nonRepudiation: true,
|
||||
keyEncipherment: true,
|
||||
dataEncipherment: true
|
||||
},
|
||||
{
|
||||
name: 'subjectKeyIdentifier',
|
||||
@@ -60,6 +63,10 @@ function buildCACert(keys, options, caCert = null) {
|
||||
name: 'extKeyUsage',
|
||||
serverAuth: true,
|
||||
critical: true,
|
||||
clientAuth: true,
|
||||
codeSigning: true,
|
||||
emailProtection: true,
|
||||
timeStamping: true
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,8 @@ const argv = yargs
|
||||
basePath: argv.path,
|
||||
commonName: argv['common-name'],
|
||||
country: argv.country,
|
||||
locality: argv.locality,
|
||||
state: argv.state,
|
||||
expired: argv.expired,
|
||||
organizations: argv.org,
|
||||
organizationalUnits: argv['org-unit'],
|
||||
@@ -103,6 +105,8 @@ const argv = yargs
|
||||
basePath: argv.path,
|
||||
commonName: argv['common-name'],
|
||||
country: argv.country,
|
||||
locality: argv.locality,
|
||||
state: argv.state,
|
||||
expired: argv.expired,
|
||||
rootCaName: argv['root-ca-name'],
|
||||
organizations: argv.org,
|
||||
@@ -158,6 +162,13 @@ const argv = yargs
|
||||
default: 'US',
|
||||
requiresArg: true,
|
||||
})
|
||||
.option('locality', {
|
||||
describe: 'Locality',
|
||||
})
|
||||
.option('state', {
|
||||
alias: 'st',
|
||||
describe: 'State',
|
||||
})
|
||||
.option('expired', {
|
||||
alias: 'e',
|
||||
describe: 'Create an expired certificate.',
|
||||
@@ -240,6 +251,8 @@ const argv = yargs
|
||||
.help('help')
|
||||
.group('common-name', 'Creation Options:')
|
||||
.group('country', 'Creation Options:')
|
||||
.group('locality', 'Creation Options:')
|
||||
.group('state', 'Creation Options:')
|
||||
.group('expired', 'Creation Options:')
|
||||
.group('org-unit', 'Creation Options:')
|
||||
.group('org', 'Creation Options:')
|
||||
|
||||
+1
-1
@@ -277,7 +277,7 @@ function createServerCert(
|
||||
expired ? 'expired ' : ''
|
||||
}server certificate was created and signed by ${caCertName}.`,
|
||||
};
|
||||
console.error(success.message);
|
||||
console.log(success.message);
|
||||
callback(null, success);
|
||||
} else {
|
||||
const err = {
|
||||
|
||||
@@ -33,6 +33,21 @@ function createSubjectAttributes(options) {
|
||||
});
|
||||
}
|
||||
|
||||
const l = _.get(options, 'locality');
|
||||
if (l) {
|
||||
attrs.push({
|
||||
shortName: 'L',
|
||||
value: l,
|
||||
});
|
||||
}
|
||||
|
||||
const st = _.get(options, 'state');
|
||||
if(st) {
|
||||
attrs.push({
|
||||
shortName: 'ST',
|
||||
value: st,
|
||||
});
|
||||
}
|
||||
return attrs;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,26 @@ describe('Testing MADCert', function() {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('Create Server Cert with locality and state', function(done) {
|
||||
try {
|
||||
certs.createServerCert('Server Locality and State', 'ca-cert-2', false, {
|
||||
locality: 'Baltimore',
|
||||
state: 'Maryland',
|
||||
basePath: global.pkiPath,
|
||||
expired: false,
|
||||
rootCaName: 'CA Cert',
|
||||
});
|
||||
const created = fs.pathExistsSync(
|
||||
path.join(global.pkiPath, 'ca-cert-2/servers/server-locality-and-state/crt.pem')
|
||||
);
|
||||
expect(created).to.be.true;
|
||||
done();
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
});
|
||||
|
||||
it('Create Server Cert with start and expiration dates', function(done) {
|
||||
try {
|
||||
certs.createServerCert('Server Valid From and To', 'ca-cert-2', false, {
|
||||
@@ -162,6 +182,24 @@ describe('Testing MADCert', function() {
|
||||
}
|
||||
});
|
||||
|
||||
it('Create User Cert with locality and state', function(done) {
|
||||
try {
|
||||
certs.createUserCert('User locality and state', caName, {
|
||||
locality: 'Baltimore',
|
||||
state: 'Maryland',
|
||||
basePath: global.pkiPath,
|
||||
expired: false,
|
||||
});
|
||||
const created = fs.pathExistsSync(
|
||||
path.join(global.pkiPath, caDir, 'users/user-locality-and-state/crt.pem')
|
||||
);
|
||||
expect(created).to.be.true;
|
||||
done();
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
});
|
||||
|
||||
it('Create User Cert with expiration before start should not be created', function(done) {
|
||||
try {
|
||||
certs.createUserCert('User Valid To before From', caName, {
|
||||
|
||||
Reference in new issue
Block a user