在Windows下让Mew 6.7兼容stunnel 5.x

Mew号称支持stunnel 5.x,但实际是有bug的。emacswiki上的解决方案是注释掉mew-ssl.el里Windows平台不支持的属性,作者自己也说是quick’n’dirty。我认为比较优雅的方式是把注释后的函数写到mew.el文件里,就是下面的函数。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
(defun mew-ssl-options (case server remoteport localport tls)
(setq server (mew-ssl-server server))
(if (= mew-ssl-ver 3)
(let (args)
(setq args
`("-c" "-f"
"-a" ,(expand-file-name (mew-ssl-cert-directory case))
"-d" ,(format "%s:%d" mew-ssl-localhost localport)
"-v" ,(number-to-string (mew-ssl-verify-level case))
"-D" "debug"
"-P" ""
"-r" ,(format "%s:%d" server remoteport)
,@mew-prog-ssl-arg))
(if tls (setq args (cons "-n" (cons tls args))))
args)
(let ((file (mew-make-temp-name)))
(with-temp-buffer
(insert "client=yes\n")
;; (insert "pid=\n")
(insert (format "verify=%d\n" (mew-ssl-verify-level case)))
;; (insert "foreground=yes\n")
(insert "debug=debug\n")
(if (and mew-ssl-libwrap (or (>= mew-ssl-ver 5) (>= mew-ssl-minor-ver 45)))
(insert "libwrap=no\n"))
;; (if (or (>= mew-ssl-ver 5) (>= mew-ssl-minor-ver 22))
;; (insert "syslog=no\n"))
(insert "CApath=" (expand-file-name (mew-ssl-cert-directory case)) "\n")
(if mew-prog-ssl-arg
(insert mew-prog-ssl-arg))
(insert (format "[%d]\n" localport))
(insert (format "accept=%s:%d\n" mew-ssl-localhost localport))
(insert (format "connect=%s:%d\n" server remoteport))
(if tls (insert (format "protocol=%s\nsslVersion=TLSv1\n" tls)))
(mew-frwlet mew-cs-dummy mew-cs-text-for-write
;; NEVER use call-process-region for privacy reasons
(write-region (point-min) (point-max) file nil 'no-msg))
(list file)))))