Skip to content

Commit f1062d0

Browse files
authored
Suppress error logs when clients connect over HTTP instead of HTTPS (#77397)
1 parent 5161049 commit f1062d0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/legacy/server/logging/log_interceptor.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
import Stream from 'stream';
2121
import { get, isEqual } from 'lodash';
2222

23-
const GET_CLIENT_HELLO = /GET_CLIENT_HELLO:http/;
23+
/**
24+
* Matches error messages when clients connect via HTTP instead of HTTPS; see unit test for full message. Warning: this can change when Node
25+
* and its bundled OpenSSL binary are upgraded.
26+
*/
27+
const OPENSSL_GET_RECORD_REGEX = /ssl3_get_record:http/;
2428

2529
function doTagsMatch(event, tags) {
2630
return isEqual(get(event, 'tags'), tags);
@@ -124,7 +128,7 @@ export class LogInterceptor extends Stream.Transform {
124128
}
125129

126130
downgradeIfHTTPWhenHTTPS(event) {
127-
return downgradeIfErrorMessage(GET_CLIENT_HELLO, event);
131+
return downgradeIfErrorMessage(OPENSSL_GET_RECORD_REGEX, event);
128132
}
129133

130134
_transform(event, enc, next) {

src/legacy/server/logging/log_interceptor.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ describe('server logging LogInterceptor', () => {
147147
describe('#downgradeIfHTTPWhenHTTPS', () => {
148148
it('transforms http requests when serving https errors', () => {
149149
const message =
150-
'40735139278848:error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request:../deps/openssl/openssl/ssl/s23_srvr.c:394';
150+
'4584650176:error:1408F09C:SSL routines:ssl3_get_record:http request:../deps/openssl/openssl/ssl/record/ssl3_record.c:322:\n';
151151
const interceptor = new LogInterceptor();
152152
const event = stubClientErrorEvent({ message });
153153
assertDowngraded(interceptor.downgradeIfHTTPWhenHTTPS(event));

0 commit comments

Comments
 (0)