Skip to content

Commit a43d7bf

Browse files
committed
Add external sasl with with key/cert (tested on freenode)
1 parent 84cc0b3 commit a43d7bf

File tree

6 files changed

+44
-6
lines changed

6 files changed

+44
-6
lines changed

config.sample.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ ircService:
7474
# Should the connection attempt to identify via SASL (if a server or user password is given)
7575
# If false, this will use PASS instead. If SASL fails, we do not fallback to PASS.
7676
sasl: false
77+
# Sasl authentication type. EXTERNAL or PLAIN are supported at the moment.
78+
saslType: "PLAIN"
7779
# Whether to allow expired certs when connecting to the IRC server.
7880
# Usually this should be off. Default: false.
7981
allowExpiredCerts: false
@@ -82,7 +84,17 @@ ircService:
8284
# -----BEGIN CERTIFICATE-----
8385
# ...
8486
# -----END CERTIFICATE-----
85-
87+
#
88+
# Explicit key/cert to use when connecting. Optional.
89+
# When setting up with https://freenode.net/kb/answer/certfp , you can copy these from the .pem file
90+
#key: |
91+
# -----BEGIN PRIVATE KEY-----
92+
# ...
93+
# -----END PRIVATE KEY-----
94+
#cert: |
95+
# -----BEGIN CERTIFICATE-----
96+
# ...
97+
# -----END CERTIFICATE-----
8698
#
8799
# The connection password to send for all clients as a PASS (or SASL, if enabled above) command. Optional.
88100
# password: 'pa$$w0rd'

config.schema.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ properties:
145145
type: "boolean"
146146
sasl:
147147
type: "boolean"
148+
saslType:
149+
type: "string"
150+
key:
151+
type: "string"
152+
cert:
153+
type: "string"
148154
allowExpiredCerts:
149155
type: "boolean"
150156
password:

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"extend": "^2.0.0",
3333
"he": "^1.1.1",
3434
"iconv": "^2.3.4",
35-
"irc": "matrix-org/node-irc#7feccae6c168c2c08527daace0c6fe5af56c6560",
35+
"irc": "matrix-org/node-irc#e005643002aac881d157e48ea62d1a40230a54b5",
3636
"js-yaml": "^3.2.7",
3737
"logform": "^2.1.2",
3838
"matrix-appservice": "^0.4.1",

src/irc/ConnectionInstance.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ export interface ConnectionOpts {
7373
nick: string;
7474
secure?: {
7575
ca?: string;
76+
key?: string;
77+
cert?: string;
7678
};
7779
encodingFallback: string;
7880
}
@@ -382,8 +384,11 @@ export class ConnectionInstance {
382384
retryCount: 0,
383385
family: server.getIpv6Prefix() || server.getIpv6Only() ? 6 : null,
384386
bustRfc3484: true,
385-
sasl: opts.password ? server.useSasl() : false,
386-
secure: server.useSsl() ? { ca: server.getCA() } : undefined,
387+
sasl: server.useSasl(),
388+
saslType: server.saslType(),
389+
secure: server.useSsl() ? {
390+
ca: server.getCA(), key: server.getKey(), cert: server.getCert()
391+
} : undefined,
387392
encodingFallback: opts.encodingFallback
388393
};
389394

src/irc/IrcServer.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,14 @@ export class IrcServer {
229229
return this.config.ca;
230230
}
231231

232+
public getKey() {
233+
return this.config.key;
234+
}
235+
236+
public getCert() {
237+
return this.config.cert;
238+
}
239+
232240
public useSsl() {
233241
return Boolean(this.config.ssl);
234242
}
@@ -241,6 +249,10 @@ export class IrcServer {
241249
return Boolean(this.config.sasl);
242250
}
243251

252+
public saslType() {
253+
return this.config.saslType;
254+
}
255+
244256
public allowExpiredCerts() {
245257
return Boolean(this.config.allowExpiredCerts);
246258
}
@@ -633,10 +645,13 @@ export interface IrcServerConfig {
633645
port?: number;
634646
icon?: string;
635647
ca?: string;
648+
key?: string;
649+
cert?: string;
636650
networkId?: string;
637651
ssl?: boolean;
638652
sslselfsign?: boolean;
639653
sasl?: boolean;
654+
saslType?: string;
640655
password?: string;
641656
allowExpiredCerts?: boolean;
642657
additionalAddresses?: string[];

0 commit comments

Comments
 (0)