mirror of
https://github.com/NationalSecurityAgency/MADCert.git
synced 2026-11-07 17:37:06 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
531be027f5 | ||
|
|
3deb4ccf9f | ||
|
|
b44c79c3af | ||
|
|
39dbf747e6 | ||
|
|
663bb10e0b | ||
|
|
0c30721bca | ||
|
|
5c976801fb | ||
|
|
e7f88431c6 | ||
|
|
f8e3721210 | ||
|
|
e8deada753 | ||
|
|
a21293fe94 | ||
|
|
b9067f2342 | ||
|
|
aa4746a13e | ||
|
|
d978f6acb9 | ||
|
|
3bc0fefe5f | ||
|
|
0828d1b4cf | ||
|
|
f14953fc14 | ||
|
|
52dae35d1d | ||
|
|
ae650a88a6 | ||
|
|
594173b92e | ||
|
|
d0d6b2ff0b | ||
|
|
8e8b3807da |
No files matched your search
+2
-1
@@ -1 +1,2 @@
|
||||
node_modules/
|
||||
node_modules/
|
||||
.idea/
|
||||
@@ -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
+290
-442
File diff suppressed because it is too large.
Load diff
+5
-5
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "madcert",
|
||||
"version": "2.2.0",
|
||||
"version": "2.5.0",
|
||||
"description": "Make a Development Cert",
|
||||
"engines": {
|
||||
"node": ">=10.16.0"
|
||||
@@ -53,13 +53,13 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"date-fns": "^2.19.0",
|
||||
"fs-extra": "^9.1.0",
|
||||
"fs-extra": "10.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"node-forge": "^0.10.0",
|
||||
"yargs": "^16.2.0"
|
||||
"node-forge": "^1.3.0",
|
||||
"yargs": "17.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.3.4",
|
||||
"mocha": "^8.3.2"
|
||||
"mocha": "9.2.0"
|
||||
}
|
||||
}
|
||||
@@ -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:')
|
||||
|
||||
+5
-3
@@ -66,9 +66,7 @@ function buildServerCert(keys, caName, caCert, localhost, options) {
|
||||
{
|
||||
name: 'keyUsage',
|
||||
digitalSignature: true,
|
||||
nonRepudiation: true,
|
||||
keyEncipherment: true,
|
||||
dataEncipherment: true,
|
||||
critical: true,
|
||||
},
|
||||
{
|
||||
@@ -195,6 +193,10 @@ function createServerCert(
|
||||
return;
|
||||
}
|
||||
|
||||
// Adding a check for the common name to be populated
|
||||
// with the name field if it is blank.
|
||||
options.commonName = _.get(options, 'commonName', serverName);
|
||||
|
||||
const serverCertPath = path.join(serverDir, '/crt.pem');
|
||||
const serverKeyPath = path.join(serverDir, '/key.pem');
|
||||
const serverP12Path = path.join(serverDir, '/bundle.p12');
|
||||
@@ -275,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,9 +41,7 @@ function buildUserCert(keys, options, caCert) {
|
||||
{
|
||||
name: 'keyUsage',
|
||||
digitalSignature: true,
|
||||
nonRepudiation: true,
|
||||
keyEncipherment: true,
|
||||
dataEncipherment: true,
|
||||
critical: true,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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