This commit is contained in:
Patrick Wagstrom 2024-11-12 18:00:25 +00:00 committed by GitHub
commit c69899f518
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -156,15 +156,38 @@ class DockerHost {
let certPath = path.join(Database.dockerTLSDir, dirName, DockerHost.CertificateFileNameCert); let certPath = path.join(Database.dockerTLSDir, dirName, DockerHost.CertificateFileNameCert);
let keyPath = path.join(Database.dockerTLSDir, dirName, DockerHost.CertificateFileNameKey); let keyPath = path.join(Database.dockerTLSDir, dirName, DockerHost.CertificateFileNameKey);
if (dockerType === "tcp" && fs.existsSync(caPath) && fs.existsSync(certPath) && fs.existsSync(keyPath)) { let key;
let ca = fs.readFileSync(caPath); let cert;
let key = fs.readFileSync(keyPath); let ca;
let cert = fs.readFileSync(certPath);
if (dockerType === "tcp") {
if (fs.existsSync(keyPath) && fs.existsSync(certPath)) {
// Load the key and cert
key = fs.readFileSync(keyPath);
cert = fs.readFileSync(certPath);
if (fs.existsSync(caPath)) {
// Condition 1: Mutual TLS with self-signed certificate
ca = fs.readFileSync(caPath);
certOptions = { certOptions = {
ca, ca,
key, key,
cert cert
}; };
} else {
// Condition 2: Mutual TLS with certificate in the standard trust store
certOptions = {
key,
cert
};
}
} else if (fs.existsSync(caPath)) {
// Condition 3: TLS using self-signed certificate (without mutual TLS)
ca = fs.readFileSync(caPath);
certOptions = {
ca
};
}
} }
return { return {