I have been trying to use open-network-stream in emacs 24.3 to interact with a server that runs the Infinote protocol on top of STARTTLS (
).
(setq myprocess (open-network-stream
"testname" ; name
"blah" ; buffer
"127.0.0.1" ; host
6523 ; port
:type 'starttls
:starttls-function 'my-starttls-function
;; sent to server when connection initially established
:end-of-capability "</stream:features>"
:end-of-command "/>"
:success "proceed"
:client-certificate '(/home/dstarr/key/dstarr.key /home/dstarr/key/dstarr.cert)
))
(defun my-starttls-function (capabilityCommandResponse)
"<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>")
</code>
The problem that I have run into is that the Infinote protocol does not emit a "greeting" upon initial connection, whereas it seems that the implementation of the function network-stream-open-starttls in lisp/net/network-stream.el expects such a greeting.
Line 214 of network-stream.el reads: (greeting (network-stream-get-response stream start eoc)).
For my particular protocol, I have eoc set to "/>", as I have to be able to detect the server's response to my starttls command (Line 266). Since my server does not emit a greeting, emacs hangs on Line 214 waiting for an "eoc" that never comes. If I set eoc to nil, emacs will proceed past that line, but it will fail to detect the starttls response (obviously, as it has no way to detect the end of a command).
To temporarily fix my issue, I removed the 'greeting' line from network-stream.el. A more robust solution would be to perhaps allow a parameter to open-network-stream that indicates whether a greeting is expected or not.
R,
Dan