View Ticket
2026-11-01
10:36 • New ticket [869df60efc] CA files loaded from a VFS fail under a non-Latin-1 locale on Tcl 9 because -encoding binary is no longer valid.. artifact: 4d26ec9f45 user: bandoti

Ticket Hash: 869df60efcf1ed8e8856b6b43fbd29084cf989be
Title: CA files loaded from a VFS fail under a non-Latin-1 locale on Tcl 9 because -encoding binary is no longer valid.
Status: Open Type: Code Defect
Severity: Important Priority: Medium
Subsystem: Resolution:
Last Modified: 2026-11-01 10:36:27
35.4 hours ago
Created: 2026-11-01 10:36:27
35.4 hours ago
Version Found In: 2.0.1
User Comments:
bandoti added on 2026-11-01 10:36:27:
Tcl 9 removed the "binary" encoding alias, so setting it fails and the channel
keeps the system encoding. A CA file with non-ASCII bytes then comes back
corrupted under any system encoding other than iso8859-1. Read it with
-translation binary, which Tcl 8.6 and 9 both accept, and stop if that fails.

diff -ruN A/generic/tls.c B/generic/tls.c
--- A/generic/tls.c
+++ B/generic/tls.c
@@ -1908,7 +1908,10 @@
     if (in == NULL) {
 	goto cleanup;
     }
-    Tcl_SetChannelOption(interp, in, "-encoding", "binary");
+    if (Tcl_SetChannelOption(interp, in, "-translation", "binary") != TCL_OK) {
+	Tcl_Close(interp, in);
+	goto cleanup;
+    }
     buf = Tcl_NewObj();
     Tcl_IncrRefCount(buf);