Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
0fb5e5ea50 | |||
35f6739b3c | |||
4634c68ea6 | |||
e126032b61 | |||
7797c799dd | |||
e8639e1b01 | |||
60a0ad106d | |||
a70c123007 | |||
46aa7620b0 | |||
f72db86e37 | |||
d612df107e | |||
1c34578c36 | |||
1f9943b5a7 | |||
67ddf97547 | |||
8a96b45ece | |||
2b6464acd5 | |||
efbb4335d7 | |||
9dd402054d |
60
changelog.md
60
changelog.md
@ -1,5 +1,65 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-03-17 - 4.1.13 - fix(tls-handshake)
|
||||||
|
Set certificate_expired TLS alert level to warning instead of fatal to allow graceful termination.
|
||||||
|
|
||||||
|
- In the TLS handshake alert for certificate_expired (0x2F), changed the alert level from 0x02 (fatal) to 0x01 (warning).
|
||||||
|
- This change avoids abrupt connection termination, enabling a smoother handling of certificate expiration alerts.
|
||||||
|
|
||||||
|
## 2025-03-17 - 4.1.12 - fix(classes.pp.connectionhandler)
|
||||||
|
Replace unrecognized_name alert data with certificate_expired alert in TLS handshake handling for session resumption without SNI
|
||||||
|
|
||||||
|
- Switched the alert payload from serverNameUnknownAlertData to a new certificateExpiredAlert buffer
|
||||||
|
- Now sends a fatal certificate_expired alert (code 47) instead of a warning unrecognized_name alert
|
||||||
|
- Improves TLS error reporting and encourages immediate disconnection when a ClientHello lacks SNI and session tickets are disallowed
|
||||||
|
|
||||||
|
## 2025-03-17 - 4.1.11 - fix(connectionhandler)
|
||||||
|
Increase delay before cleaning up connections when session resumption is blocked due to missing SNI, allowing more natural socket termination.
|
||||||
|
|
||||||
|
- Changed cleanup delay in ts/classes.pp.connectionhandler.ts from 300ms to 1000ms.
|
||||||
|
- This fix ensures that sockets get sufficient time to terminate gracefully.
|
||||||
|
|
||||||
|
## 2025-03-16 - 4.1.10 - fix(connectionhandler)
|
||||||
|
Increase delay timings for TLS alert transmission in session ticket blocking to allow graceful socket termination
|
||||||
|
|
||||||
|
- Updated finishConnection: replaced immediate socket.destroy with a graceful end call
|
||||||
|
- Increased delay after successful write from 50ms to 200ms to allow alert processing
|
||||||
|
- Raised safety timeout from 250ms to 400ms when waiting for 'drain' event
|
||||||
|
|
||||||
|
## 2025-03-16 - 4.1.9 - fix(ConnectionHandler)
|
||||||
|
Replace closeNotify alert with handshake failure alert in TLS ClientHello handling to properly signal missing SNI and enforce session ticket restrictions.
|
||||||
|
|
||||||
|
- Switched alert data sent on missing SNI from closeNotifyAlert to sslHandshakeFailureAlertData.
|
||||||
|
- Ensures consistent TLS alert behavior during handshake failure.
|
||||||
|
|
||||||
|
## 2025-03-16 - 4.1.8 - fix(ConnectionHandler/tls)
|
||||||
|
Change the TLS alert sent when a ClientHello lacks SNI: use the close_notify alert instead of handshake_failure to prompt immediate retry with SNI.
|
||||||
|
|
||||||
|
- Replaced the previously sent handshake_failure alert (code 0x28) with a close_notify alert (code 0x00) in the TLS session resumption handling in ConnectionHandler.
|
||||||
|
- This change encourages clients to immediately retry and include SNI when allowSessionTicket is false.
|
||||||
|
|
||||||
|
## 2025-03-16 - 4.1.7 - fix(classes.pp.connectionhandler)
|
||||||
|
Improve TLS alert handling in ClientHello when SNI is missing and session tickets are disallowed
|
||||||
|
|
||||||
|
- Replace the unrecognized_name alert with a handshake_failure alert to ensure better client behavior.
|
||||||
|
- Refactor the alert sending mechanism using cork/uncork and add a safety timeout for the drain event.
|
||||||
|
- Enhance logging for debugging TLS handshake failures when SNI is absent.
|
||||||
|
|
||||||
|
## 2025-03-16 - 4.1.6 - fix(tls)
|
||||||
|
Refine TLS ClientHello handling when allowSessionTicket is false by replacing extensive alert timeout logic with a concise warning alert and short delay, encouraging immediate client retry with proper SNI
|
||||||
|
|
||||||
|
- Update the TLS alert sending mechanism to use cork/uncork and a short, fixed delay instead of long timeouts
|
||||||
|
- Remove redundant event listeners and excessive cleanup logic after sending the alert
|
||||||
|
- Improve code clarity and encourage clients (e.g., Chrome) to retry handshake with SNI more responsively
|
||||||
|
|
||||||
|
## 2025-03-16 - 4.1.5 - fix(TLS/ConnectionHandler)
|
||||||
|
Improve handling of TLS session resumption without SNI by sending an 'unrecognized_name' alert instead of immediately terminating the connection. This change adds a grace period for the client to retry the handshake with proper SNI and cleans up the connection if no valid response is received.
|
||||||
|
|
||||||
|
- Send a TLS warning (unrecognized_name alert, code 112) when a ClientHello is received without SNI and session tickets are disallowed.
|
||||||
|
- Utilize socket cork/uncork to ensure the alert is sent as a single packet.
|
||||||
|
- Add a 5-second alert timeout and a subsequent 30-second grace period to allow clients to initiate a new handshake with SNI.
|
||||||
|
- Clean up and terminate the connection if no valid SNI is provided after the grace period, logging appropriate termination reasons.
|
||||||
|
|
||||||
## 2025-03-15 - 4.1.4 - fix(ConnectionHandler)
|
## 2025-03-15 - 4.1.4 - fix(ConnectionHandler)
|
||||||
Refactor ConnectionHandler code formatting for improved readability and consistency in log messages and whitespace handling
|
Refactor ConnectionHandler code formatting for improved readability and consistency in log messages and whitespace handling
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/smartproxy",
|
"name": "@push.rocks/smartproxy",
|
||||||
"version": "4.1.4",
|
"version": "4.1.13",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "A powerful proxy package that effectively handles high traffic, with features such as SSL/TLS support, port proxying, WebSocket handling, dynamic routing with authentication options, and automatic ACME certificate management.",
|
"description": "A powerful proxy package that effectively handles high traffic, with features such as SSL/TLS support, port proxying, WebSocket handling, dynamic routing with authentication options, and automatic ACME certificate management.",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartproxy',
|
name: '@push.rocks/smartproxy',
|
||||||
version: '4.1.4',
|
version: '4.1.13',
|
||||||
description: 'A powerful proxy package that effectively handles high traffic, with features such as SSL/TLS support, port proxying, WebSocket handling, dynamic routing with authentication options, and automatic ACME certificate management.'
|
description: 'A powerful proxy package that effectively handles high traffic, with features such as SSL/TLS support, port proxying, WebSocket handling, dynamic routing with authentication options, and automatic ACME certificate management.'
|
||||||
}
|
}
|
||||||
|
@ -557,16 +557,24 @@ export class ConnectionHandler {
|
|||||||
this.tlsManager.isClientHello(chunk) &&
|
this.tlsManager.isClientHello(chunk) &&
|
||||||
!serverName
|
!serverName
|
||||||
) {
|
) {
|
||||||
// Always block ClientHello without SNI when allowSessionTicket is false
|
// Block ClientHello without SNI when allowSessionTicket is false
|
||||||
console.log(
|
console.log(
|
||||||
`[${connectionId}] No SNI detected in ClientHello and allowSessionTicket=false. ` +
|
`[${connectionId}] No SNI detected in ClientHello and allowSessionTicket=false. ` +
|
||||||
`Terminating connection to force new TLS handshake with SNI.`
|
`Sending warning unrecognized_name alert to encourage immediate retry with SNI.`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Send a proper TLS alert before ending the connection
|
// Set the termination reason first
|
||||||
// Using "unrecognized_name" (112) alert which is a warning level alert (1)
|
if (record.incomingTerminationReason === null) {
|
||||||
// that encourages clients to retry with proper SNI
|
record.incomingTerminationReason = 'session_ticket_blocked_no_sni';
|
||||||
const alertData = Buffer.from([
|
this.connectionManager.incrementTerminationStat(
|
||||||
|
'incoming',
|
||||||
|
'session_ticket_blocked_no_sni'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a warning-level alert for unrecognized_name
|
||||||
|
// This encourages Chrome to retry immediately with SNI
|
||||||
|
const serverNameUnknownAlertData = Buffer.from([
|
||||||
0x15, // Alert record type
|
0x15, // Alert record type
|
||||||
0x03,
|
0x03,
|
||||||
0x03, // TLS 1.2 version
|
0x03, // TLS 1.2 version
|
||||||
@ -576,39 +584,78 @@ export class ConnectionHandler {
|
|||||||
0x70, // unrecognized_name alert (code 112)
|
0x70, // unrecognized_name alert (code 112)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Send a handshake_failure alert instead of unrecognized_name
|
||||||
|
const sslHandshakeFailureAlertData = Buffer.from([
|
||||||
|
0x15, // Alert record type
|
||||||
|
0x03,
|
||||||
|
0x03, // TLS 1.2 version
|
||||||
|
0x00,
|
||||||
|
0x02, // Length
|
||||||
|
0x01, // Warning alert level (not fatal)
|
||||||
|
0x28, // handshake_failure alert (40) instead of unrecognized_name (112)
|
||||||
|
]);
|
||||||
|
|
||||||
|
const closeNotifyAlert = Buffer.from([
|
||||||
|
0x15, // Alert record type
|
||||||
|
0x03,
|
||||||
|
0x03, // TLS 1.2 version
|
||||||
|
0x00,
|
||||||
|
0x02, // Length
|
||||||
|
0x01, // Warning alert level (1)
|
||||||
|
0x00, // close_notify alert (0)
|
||||||
|
]);
|
||||||
|
|
||||||
|
const certificateExpiredAlert = Buffer.from([
|
||||||
|
0x15, // Alert record type
|
||||||
|
0x03,
|
||||||
|
0x03, // TLS 1.2 version
|
||||||
|
0x00,
|
||||||
|
0x02, // Length
|
||||||
|
0x01, // Warning alert level (1)
|
||||||
|
0x2F, // certificate_expired alert (47)
|
||||||
|
]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
socket.write(alertData, () => {
|
// Use cork/uncork to ensure the alert is sent as a single packet
|
||||||
// Only close the socket after we're sure the alert was sent
|
socket.cork();
|
||||||
// Give the alert time to be processed by the client
|
const writeSuccessful = socket.write(certificateExpiredAlert);
|
||||||
setTimeout(() => {
|
socket.uncork();
|
||||||
|
|
||||||
|
// Function to handle the clean socket termination - but more gradually
|
||||||
|
const finishConnection = () => {
|
||||||
|
// Give Chrome more time to process the alert before closing
|
||||||
|
// We won't call destroy() at all - just end() and let the socket close naturally
|
||||||
socket.end();
|
socket.end();
|
||||||
|
|
||||||
// Ensure complete cleanup happens a bit later
|
// Log the cleanup but wait for natural closure
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!socket.destroyed) {
|
this.connectionManager.cleanupConnection(record, 'session_ticket_blocked_no_sni');
|
||||||
socket.destroy();
|
}, 1000); // Longer delay to let socket cleanup happen naturally
|
||||||
}
|
};
|
||||||
this.connectionManager.cleanupConnection(
|
|
||||||
record,
|
if (writeSuccessful) {
|
||||||
'session_ticket_blocked_no_sni'
|
// Wait longer before ending connection to ensure alert is processed by client
|
||||||
);
|
setTimeout(finishConnection, 200); // Increased from 50ms to 200ms
|
||||||
}, 100);
|
} else {
|
||||||
}, 100);
|
// If the kernel buffer was full, wait for the drain event
|
||||||
|
socket.once('drain', () => {
|
||||||
|
// Wait longer after drain as well
|
||||||
|
setTimeout(finishConnection, 200);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Safety timeout is increased too
|
||||||
|
setTimeout(() => {
|
||||||
|
socket.removeAllListeners('drain');
|
||||||
|
finishConnection();
|
||||||
|
}, 400); // Increased from 250ms to 400ms
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// If we can't send the alert, fall back to immediate termination
|
// If we can't send the alert, fall back to immediate termination
|
||||||
|
console.log(`[${connectionId}] Error sending TLS alert: ${err.message}`);
|
||||||
socket.end();
|
socket.end();
|
||||||
this.connectionManager.cleanupConnection(record, 'session_ticket_blocked_no_sni');
|
this.connectionManager.cleanupConnection(record, 'session_ticket_blocked_no_sni');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (record.incomingTerminationReason === null) {
|
|
||||||
record.incomingTerminationReason = 'session_ticket_blocked_no_sni';
|
|
||||||
this.connectionManager.incrementTerminationStat(
|
|
||||||
'incoming',
|
|
||||||
'session_ticket_blocked_no_sni'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user