info-gnus-english
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WinXP, IMAP, and SSL


From: Edi Weitz
Subject: Re: WinXP, IMAP, and SSL
Date: Fri, 08 Oct 2004 17:07:41 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (windows-nt)

FWIW, I have the same problem (WIN XP pro SP2, GNU Emacs 21.3, Gnus
5.10.6). I tried to debug this a little bit and I /think/ that the
problem is not in the Emacs Lisp code of Gnus but rather in Emacs'
internal handling of the external openssl process. Invoking openssl
from the command line works fine but the corresponding buffer in Gnus
only gets the openssl output until (and excluding) the last and most
important line which is

  * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT 
THREAD=REFERENCES SORT QUOTA IDLE AUTH=PLAIN ACL ACL2=UNION] Courier-IMAP 
ready. Copyright 1998-2004 Double Precision, Inc.  See COPYING for distribution 
information.

At that point Gnus sits and waits forever until I hit C-g.

I tried various other versions, like 21.3.50 from CVS (around July) or
OpenSSL 0.9.6m from Shining Light but the problem was still there. I
also think this is not a line-ending problem because
coding-system-for-read is already set to binary, so the process output
should arrive in the buffer, shouldn't it?

Anyway, I don't know enough about Emacs' internals to debug this
further but here's a workaround that works for me. It avoids SSL IMAP
and uses ssh port forwarding instead to provide an encrypted
connection while reading mail.

This requires that you also have a shell account on the mail server to
which you can connect via ssh without entering your password. The mail
server is configured to listen for SSL connections on 993. It also
listens for unencrypted connections on 143, but only on 127.0.0.1.

In my .gnus I have:

  (setq gnus-secondary-select-methods '((nnimap "mail-imap"
                                        (nnimap-address "localhost")     
                                        (nnimap-server-port 7777))))

In my .emacs I have:

  (defadvice imap-starttls-p (around always-nil (buffer) activate)
    ;; needed because starttls.exe doesn't work (for me) on WinXP
    nil)

  (defvar imap-tunnel-process nil
    "The process which creates the ssh connection for tunneling.")

  (defvar imap-tunnel-buffer (generate-new-buffer " *imap-tunnel*")
    "The buffer for the imap-tunnel-process.")

  (defvar real-imap-server "my.mailserver.de"
    "The real port of the imap server. Set nnimap-address to
  \"localhost\".")

  (defvar real-imap-server-port 143
    "The real port of the imap server. Set nnimap-server-port to the
  local port you want to use for forwarding.")

  (defun maybe-destroy-imap-tunnel ()
    (when (processp imap-tunnel-process)
      (message "Destroying imap tunnel")
      (kill-process imap-tunnel-process)))

  (defun maybe-create-imap-tunnel ()
    (cond ((and (processp imap-tunnel-process)
                (memq (process-status imap-tunnel-process) '(open run))))
          (t
           (maybe-destroy-imap-tunnel)
           (message "Creating imap tunnel through %s:%s via port %s"
                    real-imap-server real-imap-server-port nnimap-server-port)
           (let (done)
             (with-current-buffer imap-tunnel-buffer
               (erase-buffer)
               (when (progn
                       (setq imap-tunnel-process
                             (start-process "imap-tunnel" imap-tunnel-buffer
                                            shell-file-name shell-command-switch
                                            (format "ssh -L%s:localhost:%s %s"
                                                    nnimap-server-port 
real-imap-server-port real-imap-server)))
                       (process-kill-without-query imap-tunnel-process)
                       imap-tunnel-process)
                 (while (and (memq (process-status imap-tunnel-process) '(open 
run))
                             (goto-char (point-min))
                             (not (looking-at ".")))
                   (accept-process-output imap-tunnel-process 1)
                   (sit-for 1))
                 (setq done t)))
             (message "Creating imap tunnel through %s:%s via port %s...%s"
                      real-imap-server real-imap-server-port nnimap-server-port
                      (if done "done" "failed"))))))

  (defadvice imap-open (before imap-tunnel () activate)
    (maybe-create-imap-tunnel))

  (add-hook 'gnus-after-exiting-hook 'maybe-destroy-imap-tunnel)

In ~/.authinfo I had to add

  machine localhost login edi password frob port 7777

of course.

Cheers,
Edi.

-- 

Lisp is not dead, it just smells funny.

Real email: (replace (subseq "spamtrap@agharta.de" 5) "edi")


reply via email to

[Prev in Thread] Current Thread [Next in Thread]