Compare commits

...

4 commits

Author SHA1 Message Date
Patrick Wagstrom
ce73517c46
Merge f65453e50c into d2f71d11d6 2024-10-22 08:49:03 +00:00
Easy
d2f71d11d6
Update API URL to compatible with the latest version of ServerChan (#5227)
Some checks are pending
Auto Test / auto-test (18, ARM64) (push) Blocked by required conditions
Auto Test / auto-test (18, macos-latest) (push) Blocked by required conditions
Auto Test / auto-test (18, ubuntu-latest) (push) Blocked by required conditions
Auto Test / auto-test (18, windows-latest) (push) Blocked by required conditions
Auto Test / auto-test (20, ARM64) (push) Blocked by required conditions
Auto Test / auto-test (20, macos-latest) (push) Blocked by required conditions
Auto Test / auto-test (20, ubuntu-latest) (push) Blocked by required conditions
Auto Test / auto-test (20, windows-latest) (push) Blocked by required conditions
Auto Test / armv7-simple-test (18, ARMv7) (push) Waiting to run
Auto Test / armv7-simple-test (20, ARMv7) (push) Waiting to run
Auto Test / check-linters (push) Waiting to run
Auto Test / e2e-test (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
Merge Conflict Labeler / Labeling (push) Waiting to run
json-yaml-validate / json-yaml-validate (push) Waiting to run
2024-10-22 10:48:51 +02:00
Patrick Wagstrom
f65453e50c
fix: correct linter errors
I missed some of the `let` definitions for the ca, cert, and key when
establishing the docker TLS connection.

DCO-1.1 Signed-off-by: Patrick Wagstrom <160672+pridkett@users.noreply.github.com>
2024-09-21 18:22:37 -04:00
Patrick Wagstrom
495bf51ac8
fix: allow TLS with remote docker when using public CA
This provides a small fix that allows you to define docker hosts that
you can connect with in three different ways:

1. Mutual TLS, docker host uses non-standard CA
2. Mutual TLS, docker host uses standard CA
3. No Authentication, docker host uses non-standard CA
4. No authentication, docker host uses standard CA

In the previous implementation only condition 1 and 4 were allowed. This
makes condition 2 and 3 possible. The logic is a little messy, but it
works.

DCO-1.1 Signed-off-by: Patrick Wagstrom <160672+pridkett@users.noreply.github.com>
2024-09-21 18:01:42 -04:00
2 changed files with 35 additions and 11 deletions

View file

@ -156,15 +156,38 @@ class DockerHost {
let certPath = path.join(Database.dockerTLSDir, dirName, DockerHost.CertificateFileNameCert);
let keyPath = path.join(Database.dockerTLSDir, dirName, DockerHost.CertificateFileNameKey);
if (dockerType === "tcp" && fs.existsSync(caPath) && fs.existsSync(certPath) && fs.existsSync(keyPath)) {
let ca = fs.readFileSync(caPath);
let key = fs.readFileSync(keyPath);
let cert = fs.readFileSync(certPath);
let key;
let cert;
let ca;
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 = {
ca,
key,
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 {

View file

@ -12,8 +12,9 @@ class ServerChan extends NotificationProvider {
const okMsg = "Sent Successfully.";
// serverchan3 requires sending via ft07.com
const url = String(notification.serverChanSendKey).startsWith("sctp")
? `https://${notification.serverChanSendKey}.push.ft07.com/send`
const matchResult = String(notification.serverChanSendKey).match(/^sctp(\d+)t/i);
const url = matchResult && matchResult[1]
? `https://${matchResult[1]}.push.ft07.com/send/${notification.serverChanSendKey}.send`
: `https://sctapi.ftqq.com/${notification.serverChanSendKey}.send`;
try {