(proto-stream-open-starttls): Actually implement the starttls.el STARTTLS.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sat, 27 Nov 2010 17:35:15 +0000 (18:35 +0100)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sat, 27 Nov 2010 17:35:15 +0000 (18:35 +0100)
lisp/ChangeLog
lisp/nntp.el
lisp/proto-stream.el

index a6e9b86..9f3102d 100644 (file)
@@ -1,5 +1,10 @@
 2010-11-27  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
+       * nntp.el (nntp-open-connection): Fix the STARTTLS command syntax.
+
+       * proto-stream.el (proto-stream-open-starttls): Actually implement the
+       starttls.el STARTTLS.
+
        * color.el (color-lab->srgb): Fix function call name.
 
        * proto-stream.el (proto-stream-open-tls): Delete output from openssl
index 6dd01b0..098dff6 100644 (file)
@@ -1279,7 +1279,7 @@ password contained in '~/.nntp-authinfo'."
                          (lambda (capabilities)
                            (if (not (string-match "STARTTLS" capabilities))
                                nil
-                             "STARTTLS"))))
+                             "STARTTLS\r\n"))))
                  (funcall nntp-open-connection-function pbuffer)))
            (error nil)
            (quit
index 54d1a1c..c41ddb3 100644 (file)
@@ -149,10 +149,28 @@ command to switch on STARTTLS otherwise."
     (proto-stream-get-response stream start end-of-command)))
 
 (defun proto-stream-open-starttls (name buffer host service parameters)
-  (proto-stream-capability-open
-   (with-current-buffer buffer (point))
-   (starttls-open-stream name buffer host service)
-   parameters))
+  (let* ((start (with-current-buffer buffer (point-max)))
+        (stream (starttls-open-stream name buffer host service))
+        (greeting (proto-stream-get-response
+                   stream start (proto-stream-eoc parameters)))
+        (capabilities
+         (proto-stream-capabilities
+          stream
+          (cadr (memq :capability-command parameters))
+          (proto-stream-eoc parameters)))
+        (starttls-command
+         (funcall (cadr (memq :starttls-function parameters))
+                  capabilities)))
+    (setq start (with-current-buffer buffer (point-max)))
+    (process-send-string stream starttls-command)
+    (proto-stream-get-response stream start (proto-stream-eoc parameters))
+    (starttls-negotiate stream)
+    ;; Re-get the capabilities, since they may have changed
+    ;; after switching to TLS.
+    (setq start (with-current-buffer buffer (point-max)))
+    (process-send-string stream capability-command)
+    (list stream greeting (proto-stream-get-response
+                          stream start (proto-stream-eoc parameters)))))
 
 (defun proto-stream-get-response (stream start end-of-command)
   (with-current-buffer (process-buffer stream)