I've been trying to connect to an exchange server via IMAP using the imap4 package.
I confirmed that IMAP is working by connecting using thunderbird ... settings say it is connecting using:
---
Server name:
mail.gtaus.com.au
Connection security: STARTTLS
Authentication method: Normal password
---
This is on a windows 10 matching and I'm using the latest magicsplat distribution - tcl 8.6.9 - and as I can't access any of the
core.tcl.tk pages, I cant' get to TLS, so I'm trying to use twapi::tls_socket instead ...
I've changed imap4::open to use tls_socket ... thus
# Open a new IMAP connection and initalize the handler.
proc open {hostname {port 0}} {
variable info
variable debug
variable use_ssl
if {$debug} {
puts "I: open $hostname $port (SSL=$use_ssl)"
}
if {$use_ssl} {
# if {[info procs ::tls::socket] eq ""} {
# error "Package TLS must be loaded for secure connections."
# }
if {!$port} {
set port 993
}
# set chan [::tls::socket $hostname $port]
set chan [::twapi::tls_socket $hostname $port]
} else {
if {!$port} {
set port 143
}
set chan [socket $hostname $port]
}
fconfigure $chan -encoding binary -translation binary
# Intialize the connection state array
initinfo $chan
# Get the banner
processline $chan
# Save the banner
set info($chan,banner) [lastline $chan]
return $chan
}
then in my program ...
---
package require imap4
package require twapi
set ::imap4::use_ssl 1
set server "
mail.gtaus.com.au"
set port "143"
puts "server is $server port is $port"
set imap [::imap4::open $server $port]
---
and it crashes with this error
L:\>c:\Tcl\bin\tclsh.exe tcl\imap.tcl
server is
mail.gtaus.com.au port is 143
The token supplied to the function is invalid
while executing
"InitializeSecurityContext $Credentials $Handle $Target $Inattr 0 $Datarep $inbuflist 0"
(procedure "sspi_step" line 16)
invoked from within
"sspi_step $SspiContext $indata"
(procedure "rethrow" line 2)
invoked from within
"rethrow"
invoked from within
"trap {
lassign [sspi_step $SspiContext $indata] status outdata leftover
} onerror {} {
debuglog "sspi_step returned error: [trapresult]"
close $Socket..."
(procedure "_blocking_negotiate_loop" line 18)
invoked from within
"_blocking_negotiate_loop $chan"
(procedure "_client_blocking_negotiate" line 8)
invoked from within
"_client_blocking_negotiate $chan"
(procedure "rethrow" line 6)
invoked from within
"rethrow"
invoked from within
"trap {
set so [socket {*}$socket_args {*}$args]
_init $chan $type $so $credentials $peersubject $requestclientcert [lrange $verifier 0 end] $server
if..."
(procedure "twapi::tls::_socket" line 50)
invoked from within
"::twapi::tls_socket $hostname $port"
(procedure "::imap4::open" line 17)
invoked from within
"::imap4::open $server $port"
invoked from within
"set imap [::imap4::open $server $port]"
(file "tcl\imap.tcl" line 12)
Any ideas on what's going on greatly appreciated (in advance :).
Jonathan.