MCPcopy Index your code
hub / github.com/scality/cloudserver / assertCertPaths

Function assertCertPaths

lib/Config.js:82–112  ·  view source on GitHub ↗
(key, cert, ca, basePath)

Source from the content-addressed store, hash-verified

80};
81
82function assertCertPaths(key, cert, ca, basePath) {
83 const certObj = {};
84 certObj.paths = {};
85 certObj.certs = {};
86 if (key) {
87 const keypath = key.startsWith('/') ? key : `${basePath}/${key}`;
88 assert.doesNotThrow(() =>
89 fs.accessSync(keypath, fs.F_OK | fs.R_OK),
90 `File not found or unreachable: ${keypath}`);
91 certObj.paths.key = keypath;
92 certObj.certs.key = fs.readFileSync(keypath, 'ascii');
93 }
94 if (cert) {
95 const certpath = cert.startsWith('/') ? cert : `${basePath}/${cert}`;
96 assert.doesNotThrow(() =>
97 fs.accessSync(certpath, fs.F_OK | fs.R_OK),
98 `File not found or unreachable: ${certpath}`);
99 certObj.paths.cert = certpath;
100 certObj.certs.cert = fs.readFileSync(certpath, 'ascii');
101 }
102
103 if (ca) {
104 const capath = ca.startsWith('/') ? ca : `${basePath}/${ca}`;
105 assert.doesNotThrow(() =>
106 fs.accessSync(capath, fs.F_OK | fs.R_OK),
107 `File not found or unreachable: ${capath}`);
108 certObj.paths.ca = capath;
109 certObj.certs.ca = fs.readFileSync(capath, 'ascii');
110 }
111 return certObj;
112}
113
114function parseSproxydConfig(configSproxyd) {
115 const joiSchema = joi.object({

Callers 1

_getConfigMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected