Skip to content

Commit 7690ddd

Browse files
committed
[actions] for simplistic email servers, set rejectUnauthorized to false
resolves #91686 The poor email action has not had great success in setting TLS options correctly. Prior to 7.11, it was basically always setting `rejectUnauthorized` to false, so was never validating certificates. Starting in 7.11.0, it started respecting TLS certificates, but there are some simple/test servers in use that use self-signed certificates. The real fix for this will be the resolution of issue #80120 , but until then, this PR does a special-case check if the `secure` option is off (so the email client connects with a plain socket and then upgrades to TLS via STARTTLS) and both the user and password for the server are not set, then it will use `rejectUnauthorized: false`. Otherwise, it uses the global configured value of this setting. This also changes some other cases, where `secure: true` often did not set any `rejectUnauthorized` property at all, and so did not get verified. Now in all cases, `rejectUnauthorized` will be set, and the value will correspond to the globally configured value, except for the special case checked here, and when a proxy is in use (that logic did not change). So it is possible this would break customers, who were using insecure servers and email action worked, but with this fix the connections will be rejected. They should have been rejected all this time though. The work-around for this problem, if we don't implement a fix like this, is that customers will need to set the global `rejectUnauthorized` to `false`, which means NONE of their TLS connections for any actions will be verified. Which seems extreme.
1 parent 99a60ca commit 7690ddd

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

x-pack/plugins/actions/server/builtin_action_types/lib/send_email.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ describe('send_email module', () => {
138138
"port": 1025,
139139
"secure": false,
140140
"tls": Object {
141-
"rejectUnauthorized": true,
141+
"rejectUnauthorized": false,
142142
},
143143
},
144144
]
@@ -187,6 +187,9 @@ describe('send_email module', () => {
187187
"host": "example.com",
188188
"port": 1025,
189189
"secure": true,
190+
"tls": Object {
191+
"rejectUnauthorized": true,
192+
},
190193
},
191194
]
192195
`);

x-pack/plugins/actions/server/builtin_action_types/lib/send_email.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,13 @@ export async function sendEmail(logger: Logger, options: SendEmailOptions): Prom
8080
};
8181
transportConfig.proxy = proxySettings.proxyUrl;
8282
transportConfig.headers = proxySettings.proxyHeaders;
83-
} else if (!transportConfig.secure) {
84-
transportConfig.tls = {
85-
rejectUnauthorized,
86-
};
83+
} else if (!transportConfig.secure && user == null && password == null) {
84+
// special case - if secure:false && user:null && password:null set
85+
// rejectUnauthorized false, because simple/test servers that don't even
86+
// authenticate rarely have valid certs; eg cloud proxy, and npm maildev
87+
transportConfig.tls = { rejectUnauthorized: false };
88+
} else {
89+
transportConfig.tls = { rejectUnauthorized };
8790
}
8891
}
8992

0 commit comments

Comments
 (0)