Skip to content

Commit d2583a5

Browse files
committed
FIX: temporary fix for failed read of some HTTPS sites
1 parent 9262754 commit d2583a5

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/mezz/prot-tls.reb

+14-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ REBOL [
33
name: 'tls
44
type: 'module
55
author: rights: ["Richard 'Cyphre' Smolak" "Oldes" "Brian Dickens (Hostilefork)"]
6-
version: 0.7.3
6+
version: 0.7.4
77
history: [
88
0.6.1 "Cyphre" "Initial implementation used in old R3-alpha"
99
0.7.0 "Oldes" {
@@ -21,6 +21,7 @@ REBOL [
2121
* Added support for Chacha20-Poly1305 cipher suite
2222
}
2323
0.7.3 "Oldes" "Fixed RSA memory leak"
24+
0.7.4 "Oldes" "Pass data to parent handler even when ALERT message is not decoded"
2425
]
2526
todo: {
2627
* cached sessions
@@ -860,7 +861,7 @@ decrypt-msg: function [
860861
binary/init bin 0 ;clear the temp bin buffer
861862
]
862863
unless data [
863-
critical-error: *Alert/Bad_record_MAC
864+
; critical-error: *Alert/Bad_record_MAC
864865
]
865866
data
866867
]
@@ -1285,11 +1286,19 @@ TLS-read-data: function [
12851286
ctx/critical-error: TLS-parse-handshake-message ctx data
12861287
]
12871288
ALERT [
1289+
log-debug ["ALERT len:" :len "ctx/cipher-spec-set:" ctx/cipher-spec-set]
12881290
binary/read inp [data: BYTES :len]
12891291
if ctx/cipher-spec-set > 1 [
1292+
log-debug ["Decrypting ALERT message:" mold data]
12901293
data: decrypt-msg ctx data
1291-
;print "DECRYPTED ALERT"
1292-
;?? data
1294+
unless data [
1295+
log-error "Failed to decode ALERT message!"
1296+
;@@ TODO: inspect how it's possible that decrypt failes
1297+
;@@ problem is when CHACHA20_POLY1305 is used.
1298+
ctx/critical-error: none
1299+
ctx/protocol: 'APPLICATION ; content is reported to higher level
1300+
continue
1301+
]
12931302
]
12941303
level: data/1
12951304
id: data/2
@@ -1785,6 +1794,7 @@ TLS-awake: function [event [event!]][
17851794
]
17861795
TLS-port/data: TLS-port/state/port-data
17871796
binary/init TLS-port/state/in none ; resets input buffer
1797+
?? TLS-port/state/protocol
17881798
either 'APPLICATION = TLS-port/state/protocol [
17891799
;print "------------------"
17901800
;- report that we have data to higher layer

0 commit comments

Comments
 (0)