From bd7afd86b768b8907ce2f710872ec02d800d1f0f Mon Sep 17 00:00:00 2001 From: Igor Vinokur Date: Fri, 9 Apr 2021 09:44:46 +0300 Subject: [PATCH] Check path to be a file when reading certificates Signed-off-by: Igor Vinokur --- .../src/node/che-server-certificate-service-impl.ts | 6 ++++-- .../src/node/k8s-certificate-service-impl.ts | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/extensions/eclipse-che-theia-remote-impl-che-server/src/node/che-server-certificate-service-impl.ts b/extensions/eclipse-che-theia-remote-impl-che-server/src/node/che-server-certificate-service-impl.ts index d68b84f96..7cce9ff1a 100644 --- a/extensions/eclipse-che-theia-remote-impl-che-server/src/node/che-server-certificate-service-impl.ts +++ b/extensions/eclipse-che-theia-remote-impl-che-server/src/node/che-server-certificate-service-impl.ts @@ -31,8 +31,10 @@ export class CheServerCertificateServiceImpl implements CertificateService { const publicCertificates = await fs.readdir(PUBLIC_CRT_PATH); for (const publicCertificate of publicCertificates) { const certPath = path.join(PUBLIC_CRT_PATH, publicCertificate); - const content = await fs.readFile(certPath); - certificateAuthority.push(content); + if ((await fs.pathExists(certPath)) && (await fs.stat(certPath)).isFile()) { + const content = await fs.readFile(certPath); + certificateAuthority.push(content); + } } } diff --git a/extensions/eclipse-che-theia-remote-impl-k8s/src/node/k8s-certificate-service-impl.ts b/extensions/eclipse-che-theia-remote-impl-k8s/src/node/k8s-certificate-service-impl.ts index b3e61d709..03b1835b4 100644 --- a/extensions/eclipse-che-theia-remote-impl-k8s/src/node/k8s-certificate-service-impl.ts +++ b/extensions/eclipse-che-theia-remote-impl-k8s/src/node/k8s-certificate-service-impl.ts @@ -31,8 +31,10 @@ export class K8sCertificateServiceImpl implements CertificateService { const publicCertificates = await fs.readdir(PUBLIC_CRT_PATH); for (const publicCertificate of publicCertificates) { const certPath = path.join(PUBLIC_CRT_PATH, publicCertificate); - const content = await fs.readFile(certPath); - certificateAuthority.push(content); + if ((await fs.pathExists(certPath)) && (await fs.stat(certPath)).isFile()) { + const content = await fs.readFile(certPath); + certificateAuthority.push(content); + } } }