Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Get broken pipe error while making a https connection to a n

Deleted219235ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 25 years ago
Descriptionplain2000-10-26 05:03:57
OriginalBugID: 4653 Bug
Version: 8.3
SubmitDate: '2000-03-28'
LastModified: '2000-04-04'
Severity: LOW
Status: Assigned
Submitter: mroe
ChangedBy: sandeep
OS: Solaris
FixedDate: '2000-10-25'
ClosedDate: '2000-10-25'


Sample script:

# httpsConnect.tcl -
#
#    Short tcl test script for tcl TLS and OpenSSL.
#    Open socket connection to secure web server.

package require http
package require tls
package require base64

set ::tls::debug 1

set headers [list Authorization "Basic [base64::encode mroe:mroe]"]
set url https://elche:8016

set cvsPath   [file join / home mroe cvs]
set certFile  [file join $cvsPath xmlserver modules x509 certs client.pem]
set keyFile   [file join $cvsPath xmlserver modules x509 certs ckey.pem]
set caFile    [file join $cvsPath xmlserver modules x509 certs cacert.pem]
set caDir     [file join $cvsPath xmlserver modules x509 certs]

http::register https 443 [list ::tls::socket  -request  1  -require  1  -certfile $certFile  -keyfile  $keyFile   -cafile   $caFile    ]

http::geturl $url  -query   "test"  -headers $headers  -timeout 15000

exit 0

Run the above script while the server is not running.

Expected result:
    Same as when running this command without running http::register first,
    http::status = ioerror.

Actual result:
    error flushing "sock4": broken pipe
    while executing
"flush $s"
    ("eval" body line 35)
    (procedure "wait" line 35)
    invoked from within
"wait $token"
    (procedure "http::geturl" line 219)
    invoked from within
"http::geturl $url  -query   "test"  -headers $headers  -timeout 15000"
    (file "httpsConnect.tcl" line 53)



The problem is that we open a socket to the remote server using tls::socket, but the normal way we check whether a socket is "good" doesn't work on tls sockets.  (The normal way is to check eof on the socket and do fconfigure $sock -error.}  One way to figure out if the socket is invalid early on is to call tls::handshake on the tls socket.  But the http package currently has no way to know this when checking the connection in http::Connect.  I believe the right thing to do is to register two tls methods for doing https: tls::socket for establishing the connection and tls::handshake for checking if the connection is good.  Then http::Connect can call tls::handshake to check if the socket is good for tls sockets while doing what it usually does for normal sockets.


I believe this approach would also solve some other annoying problems that pop up due to lack of communication between the http package and tls.


For now, the work-around is to catch the geturl and massage the error message. 

-- 04/04/2000 sandeep
dkf Ticket [219235ffff]: 1 change [History diff]2001-02-05 04:30:41
hobbs Ticket [219235ffff]: 1 change [History diff]2001-09-06 08:42:26
andreas_kupries Ticket [219235ffff]: 1 change [History diff]2001-09-08 06:36:23
hobbsplain2001-09-11 07:58:40
Logged In: YES 
user_id=72656

This may have been with 8.3.1 and would need to be 
reverified in 8.3.3.  Also, this looks like it could be 
worked around, if it is really a core "bug" at all.
Log in (anonymous is fine) to add a comment.