@cloud-cli/le 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/certificate-manager.js +8 -2
- package/dist/index.js +8 -0
- package/package.json +1 -1
|
@@ -41,10 +41,16 @@ export class CertificateManager {
|
|
|
41
41
|
return statSync(join(certificatesFolder, file)).isDirectory();
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
getCertificate({ domain }) {
|
|
44
|
+
async getCertificate({ domain }) {
|
|
45
45
|
const pemFile = join(certificatesFolder, domain, 'cert.pem');
|
|
46
|
+
if (!existsSync(pemFile)) {
|
|
47
|
+
throw new Error('Invalid domain: ' + domain);
|
|
48
|
+
}
|
|
46
49
|
const out = sh('openssl', ['x509', '-in', pemFile, '-noout', '-text']);
|
|
47
|
-
|
|
50
|
+
if (out.status !== 0) {
|
|
51
|
+
throw new Error(String(out.stderr));
|
|
52
|
+
}
|
|
53
|
+
return String(out.stdout);
|
|
48
54
|
}
|
|
49
55
|
async getDomainsFromCert({ domain }) {
|
|
50
56
|
const cert = await this.getCertificate({ domain });
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
import { CertificateManager } from './certificate-manager.js';
|
|
2
2
|
const manager = new CertificateManager();
|
|
3
|
+
const readDomain = (options) => {
|
|
4
|
+
options.domain || (options.domain = options._.shift());
|
|
5
|
+
};
|
|
3
6
|
export default {
|
|
4
7
|
add(certificate) {
|
|
8
|
+
readDomain(certificate);
|
|
5
9
|
return manager.createCertificate(certificate);
|
|
6
10
|
},
|
|
7
11
|
remove(options) {
|
|
12
|
+
readDomain(options);
|
|
8
13
|
return manager.removeCertificate(options);
|
|
9
14
|
},
|
|
10
15
|
list() {
|
|
11
16
|
return manager.getCertificateList();
|
|
12
17
|
},
|
|
13
18
|
exists(options) {
|
|
19
|
+
readDomain(options);
|
|
14
20
|
return manager.certificateExists(options);
|
|
15
21
|
},
|
|
16
22
|
show(options) {
|
|
23
|
+
readDomain(options);
|
|
17
24
|
return manager.getCertificate(options);
|
|
18
25
|
},
|
|
19
26
|
showDomains(options) {
|
|
27
|
+
readDomain(options);
|
|
20
28
|
return manager.getDomainsFromCert(options);
|
|
21
29
|
}
|
|
22
30
|
};
|