Delete output from openssl if we're using tls.el.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sat, 27 Nov 2010 15:53:28 +0000 (16:53 +0100)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sat, 27 Nov 2010 15:53:28 +0000 (16:53 +0100)
lisp/ChangeLog
lisp/proto-stream.el

index d13d097..9a4f10e 100644 (file)
@@ -1,5 +1,8 @@
 2010-11-27  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
+       * proto-stream.el (proto-stream-open-tls): Delete output from openssl
+       if we're using tls.el.
+
        * nntp.el (nntp-open-connection): Switch on STARTTLS on supported
        servers.
 
index 5ec6b54..de9875f 100644 (file)
@@ -165,13 +165,23 @@ command to switch on STARTTLS otherwise."
        (buffer-substring start (point))))))
 
 (defun proto-stream-open-tls (name buffer host service parameters)
-  (proto-stream-capability-open
-   (with-current-buffer buffer (point))
-   (funcall (if (fboundp 'open-gnutls-stream)
-               'open-gnutls-stream
-             'open-tls-stream)
-           name buffer host service)
-   parameters))
+  (with-current-buffer buffer
+    (let ((start (point-max))
+         (stream
+          (funcall (if (fboundp 'open-gnutls-stream)
+                       'open-gnutls-stream
+                     'open-tls-stream)
+                   name buffer host service)))
+      ;; If we're using tls.el, we have to delete the output from
+      ;; openssl/gnutls-cli.
+      (unless (fboundp 'open-gnutls-stream)
+       (proto-stream-get-response
+        stream start (proto-stream-eoc parameters))
+       (goto-char (point-min))
+       (when (re-search-forward (proto-stream-eoc parameters) nil t)
+         (goto-char (match-beginning 0))
+         (delete-region (point-min) (line-beginning-position))))
+      (proto-stream-capability-open start stream parameters))))
 
 (defun proto-stream-open-shell (name buffer host service parameters)
   (proto-stream-capability-open
@@ -198,7 +208,7 @@ command to switch on STARTTLS otherwise."
 
 (defun proto-stream-eoc (parameters)
   (or (cadr (memq :end-of-command parameters))
-      "\n"))
+      "\r\n"))
 
 (provide 'proto-stream)