Debian Codegraph @

debian/patches/500_gnutls.patch

raw
1 Subject: Add GnuTLS support for SMTP, IMAP, POP, and NNTP
2 Author: Hiroki Sato <[email protected]>
3 Origin: https://github.com/hrs-allbsd/Mew/commit/eefffb63ed0e1c0a8381fa639c07677bf2284600
4 Origin: https://github.com/tats/Mew/tree/feature/gnutls
5
6 cf. https://groups.google.com/g/mew-ja/c/sSfEPKD_CSM
7
8 diff --git a/00copyright b/00copyright
9 index b049ccf..d7163e4 100644
10 --- a/00copyright
11 +++ b/00copyright
12 @@ -1,4 +1,4 @@
13 -Copyright (C) 1994-2015 Mew developing team.
14 +Copyright (C) 1994-2020 Mew developing team.
15 All rights reserved.
16
17 Redistribution and use in source and binary forms, with or without
18 diff --git a/00copyright.ja b/00copyright.ja
19 index 7df21de..d577401 100644
20 --- a/00copyright.ja
21 +++ b/00copyright.ja
22 @@ -1,7 +1,7 @@
23 (注) 以下は日本語の方が分かりやすい人のために、英語の著作権表示を訳し
24 た文章である。正式な著作権は、英語の原本に従う。
25
26 -Copyright (C) 1994-2015 Mew developing team.
27 +Copyright (C) 1994-2020 Mew developing team.
28 All rights reserved.
29
30 変更の有無にかかわらず、ソースおよびバイナリ形式の再配布および利用は、
31 diff --git a/00diff b/00diff
32 index 907e6aa..0383646 100644
33 --- a/00diff
34 +++ b/00diff
35 @@ -4,6 +4,10 @@
36
37 <Important Note>
38
39 +* Mew now supports GnuTLS library for TLS connections when the Emacs
40 + is built with it. To enable it, set mew-{imap,nntp,pop,smtp}-ssl to
41 + 'native.
42 +
43 * mew-smtp-port now supports Unix domain socket. If it is set to an
44 absolute pathname such as "/var/run/msp.sock", Mew will use it as a
45 Unix domain socket which supports SOCK_STREAM and understands SMTP.
46 diff --git a/info/mew.texi b/info/mew.texi
47 index a463f17..d323e3f 100644
48 --- a/info/mew.texi
49 +++ b/info/mew.texi
50 @@ -136,13 +136,13 @@ home page (http://www.Mew.org/).
51
52 @ifset ja
53 Mew とは、テキスト・メールやマルチメディア・メール(MIME)、ニュース、セ
54 -キュリティ機能(PGP、S/MIME、SSH、SSL)を便利に利用するためのユーザインター
55 +キュリティ機能(PGP、S/MIME、SSH、TLS)を便利に利用するためのユーザインター
56 フェイスです。最新の検索サービスとも連動します。
57 @end ifset
58 @ifset en
59 Mew is a user interface for text messages, multimedia messages (MIME),
60 news articles and security functionality including PGP, S/MIME, SSH,
61 -and SSL. Also, Mew can work with the recent search services.
62 +and TLS. Also, Mew can work with the recent search services.
63 @end ifset
64
65 @ifset ja
66 @@ -734,6 +734,7 @@ To read and/or write articles of NetNews, the followings are necessary.
67 @end ifset
68 @vindex mew-use-cached-passwd
69 @vindex mew-use-master-passwd
70 +@vindex mew-master-passwd-type
71
72 @ifset ja
73 メッセージを送受信したり、PGP や S/MIME を使ったりする場合には、パスワー
74 @@ -899,6 +900,90 @@ touch your Emacs. If you leave your PC and an Emacs expert happens to
75 check your configuration, your passwords could be stolen.
76 @end ifset
77
78 +@ifset ja
79 +Mew のマスターパスワード機能は Mew 独自のものですが、Emacs には
80 +auth-source と呼ばれるパスワードマネージャが含まれています。
81 +auth-source は .netrc 形式のテキストファイル、GNOME Keyring, macOS
82 +Keychain といった、プラットフォームが提供するパスワード保存機能にも対
83 +応しています。
84 +@end ifset
85 +@ifset en
86 +While the master password feature is one of the feature of Mew, Emacs
87 +supports ``auth-source'' password manager. Auth-source is similar to
88 +Mew's master password but supports variety of platform-dependent
89 +password stores including .netrc-style plain text, GNOME Keyring, and
90 +macOS Keychain.
91 +@end ifset
92 +
93 +@ifset ja
94 +Mew の auth-source 対応は、まだ実験的なものです。
95 +auth-source を試すには、マスターパスワードを使用する
96 +設定に加えて、次のように設定します。
97 +@end ifset
98 +@ifset en
99 +Note that support for auth-source is still experimental.
100 +To try auth-source, configure the following variable:
101 +@end ifset
102 +
103 +@lisp
104 +(setq mew-master-passwd-type 'auth-source)
105 +(setq auth-sources '("~/.authinfo.gpg" "~/.authinfo" "~/.netrc"))
106 +@end lisp
107 +
108 +@ifset ja
109 +どのパスワード保存機能を使用するかは、@samp{auth-sources} 変数で設定で
110 +きます。上記設定では 3 個のファイルを探し、一番最初に見つかったものを
111 +使用します。@samp{auth-sources} を指定しなかった場合、
112 +デフォルトでは .netrc 形式のテキストファイルとして、~/.authinfoと
113 +いうファイルが使われます。GnuPG を使って暗号化し、~/.authinfo.gpg とい
114 +う名前で用意すれば、暗号化した状態で維持することも可能です。平文のファ
115 +イルにパスワードを保存するのは危険ですので、暗号化しておくことを強くお
116 +勧めします。詳しくは、@xref{(auth)Top} を参照してください。
117 +@end ifset
118 +@ifset en
119 +Which password store is used can be set by @samp{auth-sources}
120 +variable. In this example, one of the three files which was found
121 +first is used. By default .netrc-style text file named
122 +``~/.authinfo'' is used. You can encrypt this file by using GnuPG and
123 +put the encrypted file as ``~/.authinfo.gpg'' and remove the original
124 +file. Mew will use the encrypted version seamlessly. It is strongly
125 +recommended to use an encrypted file to store your passwords because
126 +there is no protection in a plain text file. For more details, see
127 +@xref{(auth)Top}.
128 +@end ifset
129 +
130 +@ifset ja
131 +.netrc 形式のテキストファイルを GnuPG で暗号化した場合、Mew は保存され
132 +たパスワードの使用時に、復号用の鍵にアクセスするためのパスフレーズを尋
133 +ねます。この復号処理には、EasyPG Assistant と呼ばれる Emacs パッケージ
134 +が使われます。このパッケージは GnuPG を呼び出して暗号の処理を行なうも
135 +のです。多くの場合、デフォルトの設定で問題なく動作しますが、設定可能な
136 +項目がいくつかあります。詳しくは、@xref{(epa)Top} を参照してください。
137 +@end ifset
138 +@ifset en
139 +If you use encrypted version of the .netrc-style text file as your
140 +password store, Mew will ask you passphrase of the decryption key to
141 +retrieve passwords from the file. For encryption and decryption, an
142 +Emacs package named EasyPG Assistant, which calls GnuPG from Emacs, is
143 +used. While it works with no specific configuration in most cases,
144 +you can find several configuration knobs. For more details, see
145 +@xref{(epa)Top}.
146 +@end ifset
147 +
148 +@ifset ja
149 +現在の auth-source には、記録したパスワードを上書き・消去できないとい
150 +う大きな欠点があることに注意してください。サーバのパスワードを変更した
151 +場合は、~/.authinfo.gpg ファイルを手動で編集してください。これは、将来の
152 +Emacs で修正される見込みです。
153 +@end ifset
154 +@ifset en
155 +Note that the current version of auth-source has a big problem that it
156 +cannot delete or update the password entry in the password store. If
157 +you want to change or remove a password, you have to edit the
158 +~/.authinfo file manually. This will be fixed in the future version
159 +of Emacs.
160 +@end ifset
161 +
162 @c %%%%%%%%%%%%%%%%%
163
164 @node start, Viewing, password, Overview
165 @@ -11427,9 +11512,11 @@ POP サーバの名前。
166 @item mew-pop-ssh-server
167 POP を SSH 経由で取得する場合の SSH サーバの名前。
168 @item mew-pop-ssl
169 -POP over SSL を使うか否か。
170 +POP over TLS を使うか否か。@samp{'native} は GnuTLS
171 +を使った TLS 接続、@samp{'tunnel} は stunnel
172 +を使った TLS トンネル接続を意味する。
173 @item mew-pop-ssl-port
174 -POP over SSL のポート番号。
175 +POP over TLS のポート番号。
176 @item mew-pop-user
177 POP のアカウント名。初期値はログイン名。
178 @item mew-pop-auth
179 @@ -11461,9 +11548,11 @@ The name of your POP server.
180 @item mew-pop-ssh-server
181 The name of SSH server which forwards the POP3 port.
182 @item mew-pop-ssl
183 -If non-nil, POP connections are made over SSL.
184 +If non-nil, POP connections are made over TLS.
185 +@samp{'native} enables GnuTLS for native TLS connection
186 +and @samp{'tunnel} uses stunnel to establish a TLS tunnel.
187 @item mew-pop-ssl-port
188 -The port for POP over SSL.
189 +The port for POP over TLS.
190 @item mew-pop-user
191 The user name on your POP server. The default is your login name.
192 @item mew-pop-auth
193 @@ -11518,9 +11607,11 @@ IMAP サーバの名前。
194 @item mew-imap-ssh-server
195 IMAP を SSH 経由で取得する場合の SSH サーバの名前。
196 @item mew-imap-ssl
197 -IMAP over SSL を使うか否か。
198 +IMAP over TLS を使うか否か。@samp{'native} は GnuTLS
199 +を使った TLS 接続、@samp{'tunnel} は stunnel
200 +を使った TLS トンネル接続を意味する。
201 @item mew-imap-ssl-port
202 -IMAP over SSL のポート番号。
203 +IMAP over TLS のポート番号。
204 @item mew-imap-user
205 IMAP のアカウント名。初期値はログイン名。
206 @item mew-imap-auth
207 @@ -11548,9 +11639,11 @@ The name of your IMAP server.
208 @item mew-imap-ssh-server
209 The name of SSH server which forwards the IMAP4 port.
210 @item mew-imap-ssl
211 -If non-nil, IMAP connections are made over SSL.
212 +If non-nil, IMAP connections are made over TLS.
213 +@samp{'native} enables GnuTLS for native TLS connection
214 +and @samp{'tunnel} uses stunnel to establish a TLS tunnel.
215 @item mew-imap-ssl-port
216 -The port for IMAP over SSL.
217 +The port for IMAP over TLS.
218 @item mew-imap-user
219 The user name on the IMAP server. The default is your login name.
220 @item mew-imap-auth
221 @@ -11601,9 +11694,11 @@ NNTP サーバの名前。
222 @item mew-nntp-ssh-server
223 NNTP を SSH 経由で取得する場合の SSH サーバの名前。
224 @item mew-nntp-ssl
225 -NNTP over SSL を使うか否か。
226 +NNTP over TLS を使うか否か。@samp{'native} は GnuTLS
227 +を使った TLS 接続、@samp{'tunnel} は stunnel
228 +を使った TLS トンネル接続を意味する。
229 @item mew-nntp-ssl-port
230 -NNTP over SSL のポート番号。
231 +NNTP over TLS のポート番号。
232 @item mew-nntp-user
233 NNTP のアカウント名。もし @samp{nil} でなければ、認証の手続きが実行され
234 る。(mew-nntp-auth という変数はないことに注意。)
235 @@ -11632,9 +11727,11 @@ The name of your NNTP server.
236 @item mew-nntp-ssh-server
237 The name of SSH server which forwards the NNTP port.
238 @item mew-nntp-ssl
239 -If non-nil, NNTP connections are made over SSL.
240 +If non-nil, NNTP connections are made over TLS.
241 +@samp{'native} enables GnuTLS for native TLS connection
242 +and @samp{'tunnel} uses stunnel to establish a TLS tunnel.
243 @item mew-nntp-ssl-port
244 -The port for NNTP over SSL.
245 +The port for NNTP over TLS.
246 @item mew-nntp-user
247 The user name on the NNTP server. If non-nil, authentication is used.
248 (Note that mew-nntp-auth does not exist.)
249 @@ -11699,9 +11796,11 @@ SMTP サーバと接続する際に用いるアドレスファミリ。初期値
250 @item mew-smtp-ssh-server
251 SSH 経由でメッセージを送る際の SSH サーバの名前。
252 @item mew-smtp-ssl
253 -SMTP over SSL を使うか否か。
254 +SMTP over TLS を使うか否か。@samp{'native} は GnuTLS
255 +を使った TLS 接続、@samp{'tunnel} は stunnel
256 +を使った TLS トンネル接続を意味する。
257 @item mew-smtp-ssl-port
258 -SMTP over SSL のポート番号。
259 +SMTP over TLS のポート番号。
260 @item mew-smtp-user
261 SMTP AUTH で利用されるアカウント名。設定されない場合は、自動的にメール
262 アドレスに設定される。
263 @@ -11736,9 +11835,11 @@ The address family to be used for the SMTP server. The default value is 'ipv4.
264 @item mew-smtp-ssh-server
265 The name of SSH server which forwards the SMTP port.
266 @item mew-smtp-ssl
267 -If non-nil, SMTP connections are made over SSL.
268 +If non-nil, SMTP connections are made over TLS.
269 +@samp{'native} enables GnuTLS for native TLS connection
270 +and @samp{'tunnel} uses stunnel to establish a TLS tunnel.
271 @item mew-smtp-ssl-port
272 -The port for SMTP over SSL.
273 +The port for SMTP over TLS.
274 @item mew-smtp-user
275 The user name on your SMTP server. If not configured, your e-mail
276 address is automatically set.
277 @@ -11814,10 +11915,10 @@ configure as follows:
278 @end lisp
279
280 @ifset ja
281 -SSL (@xref{SSL})や TLS (@xref{TLS}) の章も参考にして下さい。
282 +TLS/SSL (@xref{TLS/SSL}) の章も参考にして下さい。
283 @end ifset
284 @ifset en
285 -Please refer also to SSL (@pxref{SSL}) and TLS (@pxref{TLS}).
286 +Please refer also to TLS/SSL (@pxref{TLS/SSL}).
287 @end ifset
288
289 @ifset ja
290 @@ -12350,8 +12451,10 @@ configure as follows:
291 * region:: リージョン
292 * visiting:: 移動
293 * SSH:: Secure SHell
294 -* SSL:: Secure Socket Layer
295 -* TLS:: Transport Layer Security
296 +* TLS/SSL:: Transport Layer Security / Secure Socket Layer
297 +* Stunnel:: Stunnel を使った TLS 接続
298 +* GnuTLS:: GnuTLS ライブラリを使った TLS 接続
299 +* TLS/SSL2:: TLS 接続のための変数設定
300 * spam:: スパム
301 * spam2:: スパム(2)
302 * addr-warn:: アドレスの警告
303 @@ -12362,8 +12465,10 @@ configure as follows:
304 * region:: Region
305 * visiting:: Visiting another buffer
306 * SSH:: Secure SHell
307 -* SSL:: Secure Socket Layer
308 -* TLS:: Transport Layer Security
309 +* TLS/SSL:: Transport Layer Security / Secure Socket Layer
310 +* Stunnel:: TLS by Stunnel
311 +* GnuTLS:: TLS by GnuTLS library
312 +* TLS/SSL2:: Configuration Variables for TLS
313 * spam:: Spam messages
314 * spam2:: Spam messages (2)
315 * addr-warn:: Warning addresses
316 @@ -12472,7 +12577,7 @@ name is the smallest number, type @samp{C-cC-o}.
317 @end ifset
318
319 @c %%%%%%%%%%%%%%%%%
320 -@node SSH, SSL, visiting, Tips
321 +@node SSH, TLS/SSL, visiting, Tips
322 @ifset ja
323 @section Secure SHell
324 @end ifset
325 @@ -12518,51 +12623,99 @@ in the mode line.
326 @end ifset
327
328 @ifset ja
329 -Mew の実装では、SSH と SSL/TLS を同時には使えません。SSH トンネルの中で
330 -SSL/TLS を使う必要がある場合、Mew では SSL/TLS だけを設定し、SSH トンネ
331 +Mew の実装では、SSH と TLS を同時には使えません。SSH トンネルの中で
332 +TLS を使う必要がある場合、Mew では TLS だけを設定し、SSH トンネ
333 ルはコマンドラインから張るようにして下さい。
334 @end ifset
335 @ifset en
336 -The implementation of Mew does not allow to use both SSH and SSL/TLS
337 -at the same time. If you need to use SSL/TLS over an SSH tunnel,
338 -please configure SSL/TLS only with Mew and set up an SSH tunnel on a
339 +The implementation of Mew does not allow to use both SSH and TLS
340 +at the same time. If you need to use TLS over an SSH tunnel,
341 +please configure TLS only with Mew and set up an SSH tunnel on a
342 command line.
343 @end ifset
344
345 @c %%%%%%%%%%%%%%%%%
346 -@node SSL, TLS, SSH, Tips
347 +@node TLS/SSL, Stunnel, SSH, Tips
348 @ifset ja
349 -@section Secure Socket Layer
350 +@section Transport Layer Security / Secure Socket Layer
351 @end ifset
352 @ifset en
353 -@section Secure Socket Layer
354 +@section Transport Layer Security / Secure Socket Layer
355 @end ifset
356 -@vindex mew-ssl-cert-directory
357 -@vindex mew-ssl-verify-level
358 -@vindex mew-pop-ssl
359 -@vindex mew-pop-ssl-port
360 -@vindex mew-smtp-ssl
361
362 @ifset ja
363 -SSL を使うには、認証局方式の信用モデルを理解している必要があります。現
364 -在、Mew は SSL のために "stunnel" バージョン 3、4、5 をサポートしていま
365 -す。
366 +Mew は、通信の秘匿性と完全性を保証するために、TCP 通信路の暗号化を行な
367 +う TLS (Transport Layer Security) に対応しています。
368 +この機能を使うには、Emacs に GnuTLS ライブラリが組み込まれているか、
369 +外部プログラムとして "stunnel" バージョン 3、4、5 のいずれかが必要です。
370 @end ifset
371 @ifset en
372 -Before you use SSL, you should understand the trust model of
373 -certificate authorities (CA). Currently, Mew supports "stunnel" version
374 -3, 4 and 5 for SSL.
375 +Mew supports TLS (Transport Layer Security) for confidentiality and
376 +integrity of TCP transport. To use this feature, Emacs built with
377 +GnuTLS library or a ``stunnel'' program version 3, 4, or 5 is required.
378 @end ifset
379
380 @ifset ja
381 -Mew で利用する前に、SSL サーバに対して "stunnel" で SSL のコネクション
382 +TLS プロトコルは、Netscape Communications 社が 1990 年代に開発した SSL
383 +(Secure Socket Layer) の後継として規格化されたものです。
384 +2 つのプロトコルには互換性があり、
385 +GnuTLS や ``stunnel'' プログラムは TLS と SSL の両方に対応しています。
386 +しかし、2020 年の時点で SSL には多数の脆弱性が発見されており、
387 +SSL の使用は避けて TLS のみを使用すべきだと考えられています。
388 +@end ifset
389 +@ifset en
390 +SSL (Secure Socket Layer) was developed by Netscape Communications,
391 +Inc. back in 1990s and TLS has been developed as the successor. While
392 +these two protocols are compatible with each other in some degree, and
393 +GnuTLS and ``stunnel'' support the both, as of 2020, SSL is considered
394 +as a ``should not use'' protocol because a lot of security flaws were
395 +found in the protocol.
396 +@end ifset
397 +
398 +@ifset ja
399 +TLS 機能の設定に用いる Mew の設定変数や関数の名前には、 ``ssl'' が含ま
400 +れているものがあります。混乱しやすいですが、このような歴史的な理由によ
401 +るものです。
402 +@end ifset
403 +@ifset en
404 +For this histrical reason, there are still variables and functions for
405 +TLS functionality with ``ssl'' keyword in Mew.
406 +@end ifset
407 +
408 +@ifset ja
409 +TLS を有効にするには、stunnel もしくは GnuTLS ライブラリのための変数設
410 +定を行ない、次に各プロトコルについて TLS を有効にするかどうかの設定を
411 +行ないます。
412 +@end ifset
413 +@ifset en
414 +To enable TLS functionality, you have to configure variables for
415 +``stunnel'' program or GnuTLS library, and then ones for enabling TLS
416 +of each supported protocols.
417 +@end ifset
418 +
419 +@c %%%%%%%%%%%%%%%%%
420 +@node Stunnel, GnuTLS, TLS/SSL, Tips
421 +@ifset ja
422 +@section Stunnel を使った TLS 接続
423 +@end ifset
424 +@ifset en
425 +@section TLS by Stunnel
426 +@end ifset
427 +@vindex mew-ssl-cert-directory
428 +@vindex mew-ssl-verify-level
429 +
430 +@ifset ja
431 +Mew で利用する前に、TLS サーバに対して "stunnel" で TLS のコネクション
432 が張れるか確かめて下さい。"stunnel" は、"openssl" のライブラリをリンク
433 しているので、"openssl" の知識が必要です。
434 +また、TLS を使うには、認証局方式の信用モデルを理解している必要があります。
435 @end ifset
436 @ifset en
437 -Before you use Mew with SSL, you must be sure that an SSL connection
438 -can be established to your SSL server. Since "stunnel" is linked to
439 +Before you use Mew with TLS, you must be sure that an TLS connection
440 +can be established to your TLS server. Since "stunnel" is linked to
441 the "openssl" library, you should understand "openssl".
442 +Before you use TLS, you should understand the trust model of
443 +certificate authorities (CA).
444 @end ifset
445
446 @ifset ja
447 @@ -12604,18 +12757,20 @@ To copy the certificate, do as follows:
448 @ifset ja
449 "openssl" に付いてくる証明書は、世の中で使われている CA すべてを網羅で
450 きていません。あなたが利用するサーバの証明書が、他の CA から発行された
451 -場合、その CA の証明書を同様にコピーしておく必要があります。以下のペー
452 -ジに CA の証明書がたくさん置いてあります。
453 +場合、その CA の証明書を同様にコピーしておく必要があります。インターネッ
454 +トにおいて信頼されている CA の証明書は、次の URLで管理・公開されていま
455 +す。
456 @end ifset
457 @ifset en
458 The certificates in the source of "openssl" do not cover all CAs. If
459 -the certificate of your SSL server is signed by another CA, you must
460 -copy the certificate of the CA to the directory. You may be able to
461 -find appropriate certificate from the following page:
462 +the certificate of your TLS server is signed by another CA, you must
463 +copy the certificate of the CA to the directory. You can find trusted
464 +CA certificates on Internet from the following URLs:
465 @end ifset
466
467 @example
468 -http://www.columbia.edu/~ariel/good-certs/ns45/
469 +https://www.ccadb.org
470 +https://www.mozilla.org/en-US/about/governance/policies/security-group/certs/
471 @end example
472
473 @ifset ja
474 @@ -12638,11 +12793,11 @@ It's default to 1. The meanings of the values are as follows:
475 @item 0
476 検証しない
477 @item 1
478 -サーバの証明書があれば検証する。検証結果が失敗なら、SSL/TSL コネクショ
479 -ンは作られない。証明書がなければ、SSL/TLS コネクションを作成する。
480 +サーバの証明書があれば検証する。検証結果が失敗なら、TLS コネクショ
481 +ンは作られない。証明書がなければ、TLS コネクションを作成する。
482 @item 2
483 -サーバの証明書を検証する。検証結果が失敗なら、SSL/TSL コネクションは作
484 -られない。証明書がなければ、SSL/TLS コネクションを作成しない。
485 +サーバの証明書を検証する。検証結果が失敗なら、TLS コネクションは作
486 +られない。証明書がなければ、TLS コネクションを作成しない。
487 @item 3
488 サーバが送ってきたものではなく、ローカルにインストールされている証明書
489 で検証する。
490 @@ -12652,11 +12807,11 @@ It's default to 1. The meanings of the values are as follows:
491 No verification.
492 @item 1
493 Verify server's certificate if present. If verification failed, an
494 -SSL/TLS connection is not created. If not present, an SSL/TLS
495 +TLS connection is not created. If not present, a TLS
496 connection is created.
497 @item 2
498 -Verify server's certificate. If verification failed, an SSL/TLS
499 -connection is not created. If not present, an SSL/TLS connection is
500 +Verify server's certificate. If verification failed, a TLS
501 +connection is not created. If not present, a TLS connection is
502 not created.
503 @item 3
504 Verify server's certificate which locally installed (not one from the
505 @@ -12665,14 +12820,187 @@ server).
506 @end table
507
508 @ifset ja
509 -後は各プロトコルの SSL に関する変数を設定して下しさい。たとえば、POP
510 -over SSL を利用するには、@samp{mew-pop-ssl} を @samp{t} にします。また、
511 +変数を設定したら、stunnel を使う準備は完了です。
512 +@end ifset
513 +@ifset en
514 +You can get started with using stunnel after configuring the
515 +variables.
516 +@end ifset
517 +
518 +@c %%%%%%%%%%%%%%%%%
519 +@node GnuTLS, TLS/SSL2, Stunnel, Tips
520 +@ifset ja
521 +@section GnuTLS ライブラリを使った TLS 接続
522 +@end ifset
523 +@ifset en
524 +@section TLS by GnuTLS Library
525 +@end ifset
526 +@vindex mew-ssl-trustfiles
527 +@vindex mew-ssl-verify-level
528 +@vindex gnutls-verify-error
529 +@vindex network-security-level
530 +
531 +@ifset ja
532 +GnuTLS が組み込まれた Emacs を使っている場合、TLS 機能を有効にするため
533 +の特別な設定は不要です。次の変数を設定することで、証明書の検証レベルと
534 +信頼するルート CA を変更することができます。
535 +@end ifset
536 +@ifset en
537 +Mew requires no specific configuration to support TLS if you are using
538 +an Emacs built with GnuTLS library. You can configure the certificate
539 +verification level and trusted root CAs by using the following
540 +variables.
541 +@end ifset
542 +
543 +@ifset ja
544 +証明書の検証レベルは、Emacs の Network Security Manager によって管理さ
545 +れているポリシーに従います。ポリシーを設定するには、
546 +@samp{network-security-level} という変数を使います。デフォルト値は
547 +@samp{'medium} です。@samp{'low} の場合、証明書を検証しません。
548 +@samp{'medium} の場合、ルート CA の証明書リストを使って証明書を検証し
549 +ます。検証ができなかった場合、もしくは自己署名証明書だった場合、その証
550 +明書を受け入れるかどうかのダイアログが表示されます。また、今まで証明書
551 +を使って暗号化通信が行なわれていたサーバに対して、暗号化なしでの接続が
552 +行なわれようとした場合にも、警告を表示します。@samp{'high} とすると、
553 +@samp{'medium} のチェックに加えて、サーバ証明書の鍵の変更や弱い暗号ス
554 +イートの使用に関して警告が表示されます。詳しくは、
555 +@xref{(emacs)Network Security} を参照して下さい。
556 +@end ifset
557 +@ifset en
558 +The policy for verification of the server certificates is handled by
559 +Emacs Network Security Manager. It is configured by
560 +@samp{network-security-level}, and the default value is
561 +@samp{'medium}. If it is set to @samp{'low}, no verification is
562 +performed. If @samp{'medium}, NSM will check whether the certificate
563 +used to establish the identity of the server we're connecting to can
564 +be verified by using the specified root CA list. A dialog for
565 +choosing whether the certificate should be accepted or not will be
566 +displayed if it is an invalid certificate including self-signed one.
567 +Also, if the connection is unencrypted, but it was encrypted in
568 +previous sessions, a similar dialog will be displayed. @samp{'high}
569 +will perform additional checks such as a validated certificate which
570 +changes the public key and weak cipher/protocols.
571 +For more details,
572 +see @xref{(emacs)Network Security}.
573 +@end ifset
574 +
575 +@ifset ja
576 +GnuTLS を使う場合は前述のとおり @samp{network-security-level} を設定す
577 +ることが推奨されます。一方で Mew は、Stunnel を用いた TLS 接続について、
578 +@samp{mew-ssl-verify-level} という変数を用いて証明書の検証レベルを設定
579 +していました。この変数で設定した場合との後方互換性を保つため、Mew は
580 +@samp{mew-ssl-verify-level} が @samp{0} の場合のみ、
581 +@samp{network-security-level} を @samp{'low} に自動設定します。
582 +この自動設定は、 Mew による接続のみに影響します。
583 +@samp{mew-ssl-verify-level} のデフォルト値は @samp{1} となっています。
584 +@samp{0} 以外の値の場合は、@samp{network-security-level} の設定に変更
585 +が加えられることはありません。
586 +@end ifset
587 +@ifset en
588 +It is recommended to use @samp{network-security-level} to specify the
589 +verification level when using GnuTLS. However, Mew traditionally used
590 +@samp{mew-ssl-verify-level} variable to specify the verification level
591 +for Stunnel program. To keep backward compatibility with it,
592 +@samp{network-security-level} will be temporarily set to @samp{'low}
593 +if and only if @samp{mew-ssl-verify-level} is @samp{0}. Note that the
594 +default value of @samp{mew-ssl-verify-level} is @samp{1} and there
595 +will be no change with @samp{network-security-level} when
596 +@samp{mew-ssl-verify-level} is not @samp{0}.
597 +@end ifset
598 +
599 +@ifset ja
600 +GnuTLS には、証明書の検証方法を制御するための
601 +@samp{gnutls-verify-error} という変数もあります。GnuTLS は TCP 接続の
602 +確立時に証明書の検証を行ないますが、この変数は、検証に失敗した時に切断
603 +するかどうかを制御します。デフォルトでは @samp{nil} に設定されており、
604 +検証に失敗してもすぐには切断しません。前述の Network Security Manager
605 +が、TCP 接続の確立後にチェックを行ない、切断するかどうかを決定します。
606 +すぐに切断しない設定がデフォルトとなっていることは奇妙に思われるかも知
607 +れませんが、Emacs で GnuTLS が標準的に行なう検証よりも多くの項目をチェッ
608 +クできるようにするため、TCP 接続と検証処理を分離しています。
609 +@end ifset
610 +@ifset en
611 +GnuTLS has own variable, @samp{gnutls-verify-error}, to configure the
612 +verification level. This variable controls if the TCP connection must
613 +be disconnected or not if verification of the server certificates
614 +failed upon the connection established. The default value is
615 +@samp{nil}, which means connection will not be closed immediately even
616 +when the verification fails. In this case, NSM will perform the
617 +verification and decides whether the connection should be disconnected
618 +or not. You might think it is a bit odd that the default value of
619 +this variable is set to @samp{nil}. This is because Emacs itself will
620 +check more details of the certificates and the connection than GnuTLS
621 +does. For this reason, establishing a TCP connection and decision on
622 +disconnect are separated.
623 +@end ifset
624 +
625 +@ifset ja
626 +@samp{gnutls-verify-error} を手動で設定した場合、TCP 接続の確立時に証
627 +明書の検証に失敗すると、すぐに接続が切断されます。NSM による検証は行な
628 +われません。この場合、@samp{network-security-level} や
629 +@samp{mew-ssl-verify-level} による設定は無効になりますので注意して下さ
630 +い。特別な理由がない限り、@samp{gnutls-verify-error} ではなく
631 +@samp{network-security-level} を使って設定することをお勧めします。
632 +@end ifset
633 +@ifset en
634 +If you set @samp{gnutls-verify-error} manually, GnuTLS will terminate
635 +the TCP session when the verification of the server certificates
636 +fails. In this case, no further verification by NSM will be
637 +performed. Note that configurations by using
638 +@samp{network-security-level} or @samp{mew-ssl-verify-level} will be
639 +ignored in this case. It is recommended to use
640 +@samp{network-security-level} over @samp{gnutls-verify-error} unless
641 +you have a specific reason.
642 +@end ifset
643 +
644 +@ifset ja
645 +信頼するルート CA は、@samp{mew-ssl-trustfiles} の設定に従います。ただし、
646 +GnuTLS には通常、デフォルトのルート CA リストが設定されており、Emacs
647 +26.3 とそれより前のバージョンでは、それが常に先頭に追加されます。リス
648 +トを空にしても、デフォルトのリストを無視できないことに注意してください。
649 +@end ifset
650 +@ifset en
651 +The trusted root CA list can be specified in
652 +@samp{mew-ssl-trustfiles}. However, GnuTLS has the default list of
653 +the trusted files and they are always used first on Emacs version 26.3
654 +and prior. Note that you cannot disable them even if you set an empty
655 +list to the variable.
656 +@end ifset
657 +
658 +@c %%%%%%%%%%%%%%%%%
659 +@node TLS/SSL2, spam, GnuTLS, Tips
660 +@ifset ja
661 +@section TLS 接続のための変数設定
662 +@end ifset
663 +@ifset en
664 +@section Configuration Variables for TLS
665 +@end ifset
666 +@vindex mew-ssl-default
667 +@vindex mew-pop-ssl
668 +@vindex mew-pop-ssl-port
669 +@vindex mew-smtp-ssl
670 +@vindex mew-smtp-ssl-port
671 +@vindex mew-nntp-ssl
672 +@vindex mew-nntp-ssl-port
673 +
674 +@ifset ja
675 +次に各プロトコルの TLS に関する変数を設定して下さい。たとえば、POP
676 +over TLS を利用するには、@samp{mew-pop-ssl} を @samp{t} にします。
677 +TLS の実装として stunnel もしくは GnuTLS を明示的に指定したい場合は、
678 +それぞれ @samp{'tunnel}, @samp{'native} を指定します。
679 +@samp{t} を設定したプロトコルについては、
680 +@samp{mew-ssl-default} を使って使用する実装を選択することが可能です。
681 +また、
682 ポート番号が標準と異なる場合には、@samp{mew-pop-ssl-port} を設定して下
683 さい。
684 @end ifset
685 @ifset en
686 -Then configure SSL-related variables of each protocol. For example, if
687 -you want to use POP over SSL, set @samp{mew-pop-ssl} to @samp{t}.
688 +Then configure TLS-related variables of each protocol. For example, if
689 +you want to use POP over TLS, set @samp{mew-pop-ssl} to @samp{t}.
690 +To specify the TLS implementation, @samp{'tunnel} or @samp{'native}
691 +can be used instead of @samp{t} for stunnel or GnuTLS, respectively.
692 +For protocols with @samp{t}, the value of @samp{mew-ssl-default}
693 +is used as the default TLS implementation.
694 Also, if its port is not a standard one, configure
695 @samp{mew-pop-ssl-port}.
696 @end ifset
697 @@ -12682,10 +13010,10 @@ Also, if its port is not a standard one, configure
698 @end lisp
699
700 @ifset ja
701 -SMTP で SSL を利用する場合は、以下のようにします。
702 +SMTP で TLS を利用する場合は、以下のようにします。
703 @end ifset
704 @ifset en
705 -To use SSL for SMTP, configure as follows:
706 +To use TLS for SMTP, configure as follows:
707 @end ifset
708
709 @lisp
710 @@ -12693,40 +13021,33 @@ To use SSL for SMTP, configure as follows:
711 @end lisp
712
713 @ifset ja
714 -SSL で通信が保護されている場合、モードラインに錠前の絵が表示されます。
715 +TLS で通信が保護されている場合、モードラインに錠前の絵が表示されます。
716 @end ifset
717 @ifset en
718 -While a connection is protected by SSL, a picture of a lock is shown
719 +While a connection is protected by TLS, a picture of a lock is shown
720 in the mode line.
721 @end ifset
722
723 -@c %%%%%%%%%%%%%%%%%
724 -@node TLS, spam, SSL, Tips
725 -@ifset ja
726 -@section Transport Layer Security
727 -@end ifset
728 -@ifset en
729 -@section Transport Layer Security
730 -@end ifset
731 -
732 @ifset ja
733 -Mew では SSL の代りに TLS を利用することもできます。TLS の実現は、SSL
734 -と同様 "stunnel" に頼っています。ですので、TLS を利用する際には、
735 -@xref{SSL} の説明に従って設定して下さい。
736 +Mew では、各プロトコルの STARTTLS 拡張を使い、TCP 接続の確立後に
737 +TLS を有効にすることもできます。STARTTLS を利用したい場合、ますは
738 +@xref{TLS/SSL} の説明に従って設定して下さい。
739 @end ifset
740 @ifset en
741 -Mew can use TLS instead of SSL. To enable TLS, Mew relies on
742 -@w{"}stunnel", too. So, before using TLS, you should configure
743 -according to the explanations in @ref{SSL}.
744 +Mew can upgrade a plain TCP connection to a TLS connection by using
745 +STARTTLS extension in each supported protocols. Before using this,
746 +you have to configure variables according to @ref{TLS/SSL}.
747 @end ifset
748
749 @ifset ja
750 -次に、SSL のポート番号を守りたいプロトコルと同じポート番号に設定します。
751 -たとえば、POP では以下のようにします。
752 +STARTTLS は、プロトコルの通常のポート番号と TLS 用のポート番号とを
753 +一致するように設定することで有効になります。たとえば、POP では以下のよ
754 +うにします。
755 @end ifset
756 @ifset en
757 -Then, set the SSL port to the same one of the protocol to be
758 -protected. For instance, configure as follows for POP:
759 +STARTTLS will be enabled when the port number for normal TCP
760 +connections of the protocol is set to the same as the port number for
761 +TLS connections. Configure as follows for POP, for instance:
762 @end ifset
763
764 @lisp
765 @@ -12736,19 +13057,10 @@ protected. For instance, configure as follows for POP:
766 @end lisp
767
768 @ifset ja
769 -すなわち、SSL のポート番号と保護したいプロトコルのポートが同じであれば
770 -TLS、異なれば SSL が利用されます。
771 -@end ifset
772 -@ifset en
773 -That is, if the SSL port is the same as the port of the protocol to be
774 -protected, TLS is used. Otherwise, SSL is used.
775 -@end ifset
776 -
777 -@ifset ja
778 -以下は、Message Submission を TLS で守るための設定例です。
779 +以下は、Message Submission で STARTTLS を有効にするための設定例です。
780 @end ifset
781 @ifset en
782 -The following is an example to protect Message Submission with TLS.
783 +The following is an example to enable STARTTLS for Message Submission.
784 @end ifset
785
786 @lisp
787 @@ -12758,7 +13070,7 @@ The following is an example to protect Message Submission with TLS.
788 @end lisp
789
790 @c %%%%%%%%%%%%%%%%%
791 -@node spam, spam2, TLS, Tips
792 +@node spam, spam2, TLS/SSL2, Tips
793 @ifset ja
794 @section スパム
795 @end ifset
796 diff --git a/mew-config.el b/mew-config.el
797 index 7a80b4e..8c9214f 100644
798 --- a/mew-config.el
799 +++ b/mew-config.el
800 @@ -157,6 +157,17 @@
801 (defun mew-ssl-verify-level (&optional case)
802 (mew-cfent-value case "ssl-verify-level" mew-ssl-verify-level))
803
804 +(defun mew-ssl-client-keycert-list (&optional case)
805 + (mew-cfent-value case "ssl-client-keycert-list"
806 + mew-ssl-client-keycert-list))
807 +
808 +(defun mew-ssl-trustfiles (&optional case)
809 + (mew-cfent-value case "ssl-trustfiles" mew-ssl-trustfiles))
810 +
811 +(defun mew-ssl-algorithm-priority (&optional case)
812 + (mew-cfent-value case "ssl-algorithm-priority"
813 + mew-ssl-algorithm-priority))
814 +
815 ;;
816
817 (defun mew-smtp-server (&optional case)
818 diff --git a/mew-imap.el b/mew-imap.el
819 index c07dc93..eb0a5b8 100644
820 --- a/mew-imap.el
821 +++ b/mew-imap.el
822 @@ -1224,14 +1224,18 @@
823 ;;; Opening IMAP
824 ;;;
825
826 -(defun mew-imap-open (pnm server port no-msg)
827 +(defun mew-imap-open (pnm case server port no-msg starttlsp)
828 (let ((sprt (mew-*-to-port port))
829 + (sslnp (mew-ssl-native-p (mew-imap-ssl case)))
830 pro tm)
831 (condition-case emsg
832 (progn
833 (setq tm (run-at-time mew-imap-timeout-time nil 'mew-imap-timeout))
834 (or no-msg (message "Connecting to the IMAP server..."))
835 - (setq pro (open-network-stream pnm nil server sprt))
836 + (setq pro (mew-open-network-stream pnm nil server sprt
837 + 'imap sslnp starttlsp case))
838 + (setq pro (car pro))
839 + (when (not (processp pro)) (signal 'quit nil))
840 (mew-process-silent-exit pro)
841 (mew-set-process-cs pro mew-cs-binary mew-cs-text-for-net)
842 (or no-msg (message "Connecting to the IMAP server...done")))
843 @@ -1245,7 +1249,11 @@
844 pro))
845
846 (defun mew-imap-timeout ()
847 - (signal 'quit nil))
848 + ;; Do not timeout if the NSM query pane is active.
849 + (unless (get-buffer "*Network Security Manager*")
850 + (message "IMAP connection timed out (%d seconds)"
851 + mew-imap-timeout-time)
852 + (signal 'quit nil)))
853
854 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
855 ;;;
856 @@ -1274,6 +1282,11 @@
857 (sshsrv (mew-imap-ssh-server case))
858 (sslp (mew-imap-ssl case))
859 (sslport (mew-imap-ssl-port case))
860 + (sslnp (mew-ssl-native-p (mew-imap-ssl case)))
861 + (starttlsp
862 + (mew-ssl-starttls-p (mew-imap-ssl case)
863 + (mew-*-to-string (mew-imap-port case))
864 + (mew-imap-ssl-port case)))
865 (proxysrv (mew-imap-proxy-server case))
866 (proxyport (mew-imap-proxy-port case))
867 ;; dirty but necessary for migration
868 @@ -1288,25 +1301,28 @@
869 (if (mew-imap-get-process pnm)
870 (message "Another IMAP process is running. Try later")
871 (cond
872 + (sslnp
873 + (let ((serv (if starttlsp port sslport)))
874 + (setq process (mew-imap-open pnm case server serv no-msg starttlsp))))
875 (sshsrv
876 (setq sshpro (mew-open-ssh-stream case server port sshsrv))
877 (when sshpro
878 (setq sshname (process-name sshpro))
879 (setq lport (mew-ssh-pnm-to-lport sshname))
880 (when lport
881 - (setq process (mew-imap-open pnm "localhost" lport no-msg)))))
882 + (setq process (mew-imap-open pnm case "localhost" lport no-msg nil)))))
883 (sslp
884 - (if (mew-port-equal port sslport) (setq tls mew-tls-imap))
885 + (when starttlsp (setq tls mew-tls-imap))
886 (setq sslpro (mew-open-ssl-stream case server sslport tls))
887 (when sslpro
888 (setq sslname (process-name sslpro))
889 (setq lport (mew-ssl-pnm-to-lport sslname))
890 (when lport
891 - (setq process (mew-imap-open pnm mew-ssl-localhost lport no-msg)))))
892 + (setq process (mew-imap-open pnm case mew-ssl-localhost lport no-msg nil)))))
893 (proxysrv
894 - (setq process (mew-imap-open pnm proxysrv proxyport no-msg)))
895 + (setq process (mew-imap-open pnm case proxysrv proxyport no-msg nil)))
896 (t
897 - (setq process (mew-imap-open pnm server port no-msg))))
898 + (setq process (mew-imap-open pnm case server port no-msg nil))))
899 (if (null process)
900 (when (eq directive 'exec)
901 (mew-imap-exec-recover bnm))
902 @@ -1403,7 +1419,15 @@
903 ;;
904 (set-process-sentinel process 'mew-imap-sentinel)
905 (set-process-filter process 'mew-imap-filter)
906 - (set-process-buffer process buf)))))
907 + (set-process-buffer process buf)
908 + ;;
909 + (when sslnp
910 + ;; GnuTLS requires a client-initiated command after the
911 + ;; session is established or upgraded to use TLS because
912 + ;; no additional greeting from the server.
913 + (mew-imap-set-status pnm "capability")
914 + (mew-imap-command-capability process pnm))
915 + ))))
916
917 (defun mew-imap-exec-recover (bnm)
918 (mew-summary-visible-buffer bnm)
919 @@ -1888,7 +1912,7 @@
920
921 ;;; Copyright Notice:
922
923 -;; Copyright (C) 2002-2015 Mew developing team.
924 +;; Copyright (C) 2002-2020 Mew developing team.
925 ;; All rights reserved.
926
927 ;; Redistribution and use in source and binary forms, with or without
928 diff --git a/mew-imap2.el b/mew-imap2.el
929 index 49b8231..3c46bd4 100644
930 --- a/mew-imap2.el
931 +++ b/mew-imap2.el
932 @@ -360,14 +360,18 @@
933 ;;; Opening IMAP
934 ;;;
935
936 -(defun mew-imap2-open (pnm server port)
937 +(defun mew-imap2-open (pnm case server port starttlsp)
938 (let ((sprt (mew-*-to-port port))
939 + (sslnp (mew-ssl-native-p (mew-imap-ssl case)))
940 pro tm)
941 (condition-case emsg
942 (progn
943 (setq tm (run-at-time mew-imap-timeout-time nil 'mew-imap2-timeout))
944 (message "Connecting to the IMAP server...")
945 - (setq pro (open-network-stream pnm nil server sprt))
946 + (setq pro (mew-open-network-stream pnm nil server sprt
947 + 'imap sslnp starttlsp case))
948 + (setq pro (car pro))
949 + (when (not (processp pro)) (signal 'quit nil))
950 (mew-process-silent-exit pro)
951 (mew-set-process-cs pro mew-cs-text-for-net mew-cs-text-for-net)
952 (message "Connecting to the IMAP server...done"))
953 @@ -381,7 +385,11 @@
954 pro))
955
956 (defun mew-imap2-timeout ()
957 - (signal 'quit nil))
958 + ;; Do not timeout if the NSM query pane is active.
959 + (unless (get-buffer "*Network Security Manager*")
960 + (message "IMAP connection timed out (%d seconds)"
961 + mew-imap-timeout-time)
962 + (signal 'quit nil)))
963
964 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
965 ;;;
966 @@ -396,29 +404,37 @@
967 (sshsrv (mew-imap-ssh-server case))
968 (sslp (mew-imap-ssl case))
969 (sslport (mew-imap-ssl-port case))
970 + (sslnp (mew-ssl-native-p (mew-imap-ssl case)))
971 + (starttlsp
972 + (mew-ssl-starttls-p (mew-imap-ssl case)
973 + (mew-*-to-string (mew-imap-port case))
974 + (mew-imap-ssl-port case)))
975 (proxysrv (mew-imap-proxy-server case))
976 (proxyport (mew-imap-proxy-port case))
977 process sshname sshpro sslname sslpro lport tls)
978 (cond
979 + (sslnp
980 + (let ((serv (if starttlsp port sslport)))
981 + (setq process (mew-imap2-open pnm case server serv starttlsp))))
982 (sshsrv
983 (setq sshpro (mew-open-ssh-stream case server port sshsrv))
984 (when sshpro
985 (setq sshname (process-name sshpro))
986 (setq lport (mew-ssh-pnm-to-lport sshname))
987 (when lport
988 - (setq process (mew-imap2-open pnm "localhost" lport)))))
989 + (setq process (mew-imap2-open pnm case "localhost" lport nil)))))
990 (sslp
991 - (if (mew-port-equal port sslport) (setq tls mew-tls-imap))
992 + (when starttlsp (setq tls mew-tls-imap))
993 (setq sslpro (mew-open-ssl-stream case server sslport tls))
994 (when sslpro
995 (setq sslname (process-name sslpro))
996 (setq lport (mew-ssl-pnm-to-lport sslname))
997 (when lport
998 - (setq process (mew-imap2-open pnm mew-ssl-localhost lport)))))
999 + (setq process (mew-imap2-open pnm case mew-ssl-localhost lport nil)))))
1000 (proxysrv
1001 - (setq process (mew-imap2-open pnm proxysrv proxyport)))
1002 + (setq process (mew-imap2-open pnm case proxysrv proxyport nil)))
1003 (t
1004 - (setq process (mew-imap2-open pnm server port))))
1005 + (setq process (mew-imap2-open pnm case server port nil))))
1006 (if (null process)
1007 (cond
1008 ((and sshsrv (null sshpro))
1009 @@ -448,7 +464,14 @@
1010 (set-process-buffer process nil)
1011 (set-process-sentinel process 'mew-imap2-sentinel)
1012 (set-process-filter process 'mew-imap2-filter)
1013 - (message "Copying in background..."))))
1014 + (message "Copying in background...")
1015 + (when sslnp
1016 + ;; GnuTLS requires a client-initiated command after the
1017 + ;; session is established or upgraded to use TLS because
1018 + ;; no additional greeting from the server.
1019 + (mew-imap2-set-status pnm "capability")
1020 + (mew-imap2-command-capability process pnm))
1021 + )))
1022
1023 (defun mew-summary-from-local-to-imap ()
1024 "Copy messages in local folders under specified folder prefix
1025 @@ -628,7 +651,7 @@ with '*' in the region are handled."
1026
1027 ;;; Copyright Notice:
1028
1029 -;; Copyright (C) 2003-2015 Mew developing team.
1030 +;; Copyright (C) 2003-2020 Mew developing team.
1031 ;; All rights reserved.
1032
1033 ;; Redistribution and use in source and binary forms, with or without
1034 diff --git a/mew-net.el b/mew-net.el
1035 index 2206b28..ef78c51 100644
1036 --- a/mew-net.el
1037 +++ b/mew-net.el
1038 @@ -14,9 +14,7 @@
1039
1040 (defvar mew-port-db
1041 '(("smtp" 25)
1042 - ;; This is officially assigned to another service (urd) by IANA.
1043 - ;; IESG will never assign a port number to SMTP over SSL...
1044 - ("smtps" 465)
1045 + ("smtps" 465) ; RFC 8314
1046 ("pop3" 110)
1047 ("pop3s" 995)
1048 ("nntp" 119)
1049 @@ -881,7 +879,7 @@ The messages in the server side is always retained."
1050
1051 ;;; Copyright Notice:
1052
1053 -;; Copyright (C) 2002-2015 Mew developing team.
1054 +;; Copyright (C) 2002-2020 Mew developing team.
1055 ;; All rights reserved.
1056
1057 ;; Redistribution and use in source and binary forms, with or without
1058 diff --git a/mew-nntp.el b/mew-nntp.el
1059 index e9c3352..bf3ddc7 100644
1060 --- a/mew-nntp.el
1061 +++ b/mew-nntp.el
1062 @@ -388,14 +388,18 @@
1063 ;;; Opening NNTP
1064 ;;;
1065
1066 -(defun mew-nntp-open (pnm server port no-msg)
1067 +(defun mew-nntp-open (pnm case server port no-msg starttlsp)
1068 (let ((sprt (mew-*-to-port port))
1069 + (sslnp (mew-ssl-native-p (mew-nntp-ssl case)))
1070 pro tm)
1071 (condition-case emsg
1072 (progn
1073 (setq tm (run-at-time mew-nntp-timeout-time nil 'mew-nntp-timeout))
1074 (or no-msg (message "Connecting to the NNTP server..."))
1075 - (setq pro (open-network-stream pnm nil server sprt))
1076 + (setq pro (mew-open-network-stream pnm nil server sprt
1077 + 'nntp sslnp starttlsp case))
1078 + (setq pro (car pro))
1079 + (when (not (processp pro)) (signal 'quit nil))
1080 (mew-process-silent-exit pro)
1081 (mew-set-process-cs pro mew-cs-text-for-net mew-cs-text-for-net)
1082 (or no-msg (message "Connecting to the NNTP server...done")))
1083 @@ -409,7 +413,11 @@
1084 pro))
1085
1086 (defun mew-nntp-timeout ()
1087 - (signal 'quit nil))
1088 + ;; Do not timeout if the NSM query pane is active.
1089 + (unless (get-buffer "*Network Security Manager*")
1090 + (message "NNTP connection timed out (%d seconds)"
1091 + mew-nntp-timeout-time)
1092 + (signal 'quit nil)))
1093
1094 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1095 ;;;
1096 @@ -423,6 +431,11 @@
1097 (sshsrv (mew-nntp-ssh-server case))
1098 (sslp (mew-nntp-ssl case))
1099 (sslport (mew-nntp-ssl-port case))
1100 + (sslnp (mew-ssl-native-p (mew-nntp-ssl case)))
1101 + (starttlsp
1102 + (mew-ssl-starttls-p (mew-nntp-ssl case)
1103 + (mew-*-to-string (mew-nntp-port case))
1104 + (mew-nntp-ssl-port case)))
1105 (newsgroup (mew-bnm-to-newsgroup bnm))
1106 (pnm (mew-nntp-info-name case newsgroup))
1107 (buf (get-buffer-create (mew-nntp-buffer-name pnm)))
1108 @@ -432,23 +445,26 @@
1109 (if (mew-nntp-get-process pnm)
1110 (message "Another NNTP process is running. Try later")
1111 (cond
1112 + (sslnp
1113 + (let ((serv (if starttlsp port sslport)))
1114 + (setq process (mew-nntp-open pnm case server serv no-msg starttlsp))))
1115 (sshsrv
1116 (setq sshpro (mew-open-ssh-stream case server port sshsrv))
1117 (when sshpro
1118 (setq sshname (process-name sshpro))
1119 (setq lport (mew-ssh-pnm-to-lport sshname))
1120 (when lport
1121 - (setq process (mew-nntp-open pnm "localhost" lport no-msg)))))
1122 + (setq process (mew-nntp-open pnm case "localhost" lport no-msg nil)))))
1123 (sslp
1124 - (if (mew-port-equal port sslport) (setq tls mew-tls-nntp))
1125 + (when starttlsp (setq tls mew-tls-nntp))
1126 (setq sslpro (mew-open-ssl-stream case server sslport tls))
1127 (when sslpro
1128 (setq sslname (process-name sslpro))
1129 (setq lport (mew-ssl-pnm-to-lport sslname))
1130 (when lport
1131 - (setq process (mew-nntp-open pnm mew-ssl-localhost lport no-msg)))))
1132 + (setq process (mew-nntp-open pnm case mew-ssl-localhost lport no-msg nil)))))
1133 (t
1134 - (setq process (mew-nntp-open pnm server port no-msg))))
1135 + (setq process (mew-nntp-open pnm case server port no-msg nil))))
1136 (when process
1137 (mew-summary-lock process "NNTPing" (or sshpro sslpro))
1138 (mew-sinfo-set-summary-form (mew-get-summary-form bnm))
1139 @@ -502,7 +518,13 @@
1140 (mew-sinfo-set-start-point (point)) ;; after erase-buffer
1141 (set-process-sentinel process 'mew-nntp-sentinel)
1142 (set-process-filter process 'mew-nntp-filter)
1143 - (set-process-buffer process buf)))))
1144 + (set-process-buffer process buf)
1145 + (when sslnp
1146 + ;; GnuTLS requires a client-initiated command after the
1147 + ;; session is established or upgraded to use TLS because
1148 + ;; no additional greeting from the server.
1149 + (mew-nntp-command-mode-reader process pnm))
1150 + ))))
1151
1152 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1153 ;;;
1154 @@ -713,7 +735,7 @@
1155
1156 ;;; Copyright Notice:
1157
1158 -;; Copyright (C) 1999-2015 Mew developing team.
1159 +;; Copyright (C) 1999-2020 Mew developing team.
1160 ;; All rights reserved.
1161
1162 ;; Redistribution and use in source and binary forms, with or without
1163 diff --git a/mew-nntp2.el b/mew-nntp2.el
1164 index 4c12458..1f314f2 100644
1165 --- a/mew-nntp2.el
1166 +++ b/mew-nntp2.el
1167 @@ -177,14 +177,18 @@
1168 ;;; Opening NNTP
1169 ;;;
1170
1171 -(defun mew-nntp2-open (pnm server port)
1172 +(defun mew-nntp2-open (pnm case server port starttlsp)
1173 (let ((sprt (mew-*-to-port port))
1174 + (sslnp (mew-ssl-native-p (mew-nntp-ssl case)))
1175 pro tm)
1176 (condition-case emsg
1177 (progn
1178 (setq tm (run-at-time mew-nntp-timeout-time nil 'mew-nntp2-timeout))
1179 (message "Connecting to the NNTP server...")
1180 - (setq pro (open-network-stream pnm nil server sprt))
1181 + (setq pro (mew-open-network-stream pnm nil server sprt
1182 + 'nntp sslnp starttlsp case))
1183 + (setq pro (car pro))
1184 + (when (not (processp pro)) (signal 'quit nil))
1185 (mew-process-silent-exit pro)
1186 (mew-set-process-cs pro mew-cs-text-for-net mew-cs-text-for-net)
1187 (message "Connecting to the NNTP server...done"))
1188 @@ -198,7 +202,11 @@
1189 pro))
1190
1191 (defun mew-nntp2-timeout ()
1192 - (signal 'quit nil))
1193 + ;; Do not timeout if the NSM query pane is active.
1194 + (unless (get-buffer "*Network Security Manager*")
1195 + (message "NNTP connection timed out (%d seconds)"
1196 + mew-nntp-timeout-time)
1197 + (signal 'quit nil)))
1198
1199 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1200 ;;;
1201 @@ -213,25 +221,33 @@
1202 (sshsrv (mew-nntp-ssh-server case))
1203 (sslp (mew-nntp-ssl case))
1204 (sslport (mew-nntp-ssl-port case))
1205 + (sslnp (mew-ssl-native-p (mew-nntp-ssl case)))
1206 + (starttlsp
1207 + (mew-ssl-starttls-p (mew-nntp-ssl case)
1208 + (mew-*-to-string (mew-nntp-port case))
1209 + (mew-nntp-ssl-port case)))
1210 process sshname sshpro sslname sslpro lport tls)
1211 (cond
1212 + (sslnp
1213 + (let ((serv (if starttlsp port sslport)))
1214 + (setq process (mew-nntp2-open pnm case server serv starttlsp))))
1215 (sshsrv
1216 (setq sshpro (mew-open-ssh-stream case server port sshsrv))
1217 (when sshpro
1218 (setq sshname (process-name sshpro))
1219 (setq lport (mew-ssh-pnm-to-lport sshname))
1220 (when lport
1221 - (setq process (mew-nntp2-open pnm "localhost" lport)))))
1222 + (setq process (mew-nntp2-open pnm case "localhost" lport nil)))))
1223 (sslp
1224 - (if (mew-port-equal port sslport) (setq tls mew-tls-nntp))
1225 + (when starttlsp (setq tls mew-tls-nntp))
1226 (setq sslpro (mew-open-ssl-stream case server sslport tls))
1227 (when sslpro
1228 (setq sslname (process-name sslpro))
1229 (setq lport (mew-ssl-pnm-to-lport sslname))
1230 (when lport
1231 - (setq process (mew-nntp2-open pnm mew-ssl-localhost lport)))))
1232 + (setq process (mew-nntp2-open pnm case mew-ssl-localhost lport nil)))))
1233 (t
1234 - (setq process (mew-nntp2-open pnm server port))))
1235 + (setq process (mew-nntp2-open pnm case server port nil))))
1236 (if (null process)
1237 (cond
1238 ((and sshsrv (null sshpro))
1239 @@ -256,8 +272,13 @@
1240 (set-process-buffer process nil)
1241 (set-process-sentinel process 'mew-nntp2-sentinel)
1242 (set-process-filter process 'mew-nntp2-filter)
1243 - (message "Posting in background..."))))
1244 -
1245 + (message "Posting in background...")
1246 + (when sslnp
1247 + ;; GnuTLS requires a client-initiated command after the
1248 + ;; session is established or upgraded to use TLS because
1249 + ;; no additional greeting from the server.
1250 + (mew-nntp-command-mode-reader process pnm))
1251 + )))
1252 (defun mew-nntp2-flush-queue (case &optional qfld)
1253 (let (msgs)
1254 (unless qfld (setq qfld (mew-postq-folder case)))
1255 @@ -417,7 +438,7 @@
1256
1257 ;;; Copyright Notice:
1258
1259 -;; Copyright (C) 1999-2015 Mew developing team.
1260 +;; Copyright (C) 1999-2020 Mew developing team.
1261 ;; All rights reserved.
1262
1263 ;; Redistribution and use in source and binary forms, with or without
1264 diff --git a/mew-passwd.el b/mew-passwd.el
1265 index 9604901..838257b 100644
1266 --- a/mew-passwd.el
1267 +++ b/mew-passwd.el
1268 @@ -35,12 +35,100 @@
1269 ;;;
1270
1271 (defun mew-passwd-get-passwd (key)
1272 - (nth 1 (assoc key mew-passwd-alist)))
1273 + (cond
1274 + ((mew-passwd-use-auth-source-p)
1275 + (mew-passwd-auth-source-get-passwd key))
1276 + (t (nth 1 (assoc key mew-passwd-alist)))))
1277
1278 (defun mew-passwd-set-passwd (key val)
1279 - (if (assoc key mew-passwd-alist)
1280 - (setcar (nthcdr 1 (assoc key mew-passwd-alist)) val)
1281 - (setq mew-passwd-alist (cons (list key val 0) mew-passwd-alist))))
1282 + (cond
1283 + ((mew-passwd-use-auth-source-p)
1284 + (mew-passwd-auth-source-set-passwd key val))
1285 + (t (if (assoc key mew-passwd-alist)
1286 + (setcar (nthcdr 1 (assoc key mew-passwd-alist)) val)
1287 + (setq mew-passwd-alist (cons (list key val 0) mew-passwd-alist))))))
1288 +
1289 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1290 +;;;
1291 +;;; Functions for auth-source backend
1292 +;;;
1293 +
1294 +(autoload 'auth-source-search "auth-source")
1295 +
1296 +(defun mew-passwd-use-auth-source-p ()
1297 + (eq mew-master-passwd-type 'auth-source))
1298 +
1299 +(defun mew-passwd-auth-source-parse-key (key)
1300 + (let ((st (split-string key "[@:]")))
1301 + (list :user (nth 0 st)
1302 + :host (nth 1 st)
1303 + :port (nth 2 st))))
1304 +
1305 +;;; XXX will be revisited.
1306 +(defun mew-passwd-auth-source-parse-key-x (key)
1307 + (if (string-match "\\([^@]+\\)@\\([^:]+\\):\\(.+\\)" key)
1308 + (list :user (match-string 1 key)
1309 + :host (match-string 2 key)
1310 + :port (match-string 3 key))
1311 + (list :key key
1312 + :user nil
1313 + :host nil
1314 + :port nil)))
1315 +
1316 +;;; XXX epa-pinentry-mode is set to 'loopback to avoid GUI pinentry
1317 +;;; window. This might not be a recommended way but it works.
1318 +;;;
1319 +;;; XXX when the backend is an encrypted file and an wrong passphrase
1320 +;;; is provided, a password prompt will be displayed. This may be
1321 +;;; confusing.
1322 +(defun mew-passwd-auth-source-get-passwd (key)
1323 + (let* ((epa-pinentry-mode 'loopback)
1324 + (slist (mew-passwd-auth-source-parse-key key))
1325 + found)
1326 + (cond
1327 + ((member key mew-pgp-list)
1328 + ;; Never get GnuPG passphrase. Rely on gpg-agent for caching.
1329 + (setq found nil))
1330 + (t
1331 + (condition-case error
1332 + (setq found (apply #'auth-source-search (nconc slist)))
1333 + (error
1334 + (setq found nil)))))
1335 + (if found
1336 + (let ((secret (plist-get (nth 0 found) :secret)))
1337 + (if (functionp secret)
1338 + (funcall secret)
1339 + secret))
1340 + nil)))
1341 +
1342 +(defun mew-passwd-auth-source-set-passwd (key val)
1343 + (cond
1344 + ((member key mew-pgp-list)
1345 + ;; Never store GnuPG passphrase. Rely on gpg-agent for caching.
1346 + )
1347 + (val
1348 + ;; Authenticated successfully.
1349 + (let* ((epa-pinentry-mode 'loopback)
1350 + (slist (mew-passwd-auth-source-parse-key key))
1351 + (entry (apply #'auth-source-search
1352 + (append slist (list
1353 + :secret val :create t))))
1354 + (save-function (plist-get (nth 0 entry) :save-function)))
1355 + (when (functionp save-function)
1356 + (funcall save-function))))
1357 + (t
1358 + ;; Authentication failed.
1359 + ;;
1360 + ;; XXX: removal of the wrong password is not supported by any
1361 + ;; backends (i.e. auth-source-delete is noop).
1362 + (let* ((epa-pinentry-mode 'loopback)
1363 + (slist (mew-passwd-auth-source-parse-key key))
1364 + (num (apply #'auth-source-forget+ (nconc slist)))
1365 + (entry (apply #'auth-source-delete (nconc slist)))
1366 + (save-function (plist-get (nth 0 entry) :save-function)))
1367 + (when (functionp save-function)
1368 + (funcall save-function))
1369 + (message "Wrong password is stored. Please remove it manually.")))))
1370
1371 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1372 ;;;
1373 @@ -95,14 +183,19 @@
1374 (mew-timer (* mew-passwd-timer-unit 60) 'mew-passwd-timer))))
1375
1376 (defun mew-passwd-setup-master ()
1377 - (when (and (not mew-passwd-master) mew-use-master-passwd)
1378 + (cond
1379 + ((mew-passwd-use-auth-source-p)
1380 + ;;; do nothing
1381 + )
1382 + (t
1383 + (when (and (not mew-passwd-master) mew-use-master-passwd)
1384 (setq mew-passwd-agent-hack (mew-passwd-check-agent-hack))
1385 (let ((file (expand-file-name mew-passwd-file mew-conf-path)))
1386 (if (file-exists-p file)
1387 (setq mew-passwd-alist (mew-passwd-load))
1388 ;; save nil and ask master twice
1389 (mew-passwd-save)))
1390 - (add-hook 'kill-emacs-hook 'mew-passwd-clean-up)))
1391 + (add-hook 'kill-emacs-hook 'mew-passwd-clean-up)))))
1392
1393 (defun mew-passwd-clean-up ()
1394 (remove-hook 'kill-emacs-hook 'mew-passwd-clean-up)
1395 diff --git a/mew-pop.el b/mew-pop.el
1396 index 9e2db7c..5ff3783 100644
1397 --- a/mew-pop.el
1398 +++ b/mew-pop.el
1399 @@ -610,14 +610,18 @@
1400 ;;; Opening POP
1401 ;;;
1402
1403 -(defun mew-pop-open (pnm server port no-msg)
1404 +(defun mew-pop-open (pnm case server port no-msg starttlsp)
1405 (let ((sprt (mew-*-to-port port))
1406 + (sslnp (mew-ssl-native-p (mew-pop-ssl case)))
1407 pro tm)
1408 (condition-case emsg
1409 (progn
1410 (setq tm (run-at-time mew-pop-timeout-time nil 'mew-pop-timeout))
1411 (or no-msg (message "Connecting to the POP server..."))
1412 - (setq pro (open-network-stream pnm nil server sprt))
1413 + (setq pro (mew-open-network-stream pnm nil server sprt
1414 + 'pop sslnp starttlsp case))
1415 + (setq pro (car pro))
1416 + (when (not (processp pro)) (signal 'quit nil))
1417 (mew-process-silent-exit pro)
1418 (mew-set-process-cs pro mew-cs-text-for-net mew-cs-text-for-net)
1419 (or no-msg (message "Connecting to the POP server...done")))
1420 @@ -631,7 +635,11 @@
1421 pro))
1422
1423 (defun mew-pop-timeout ()
1424 - (signal 'quit nil))
1425 + ;; Do not timeout if the NSM query pane is active.
1426 + (unless (get-buffer "*Network Security Manager*")
1427 + (message "POP connection timed out (%d seconds)"
1428 + mew-pop-timeout-time)
1429 + (signal 'quit nil)))
1430
1431 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1432 ;;;
1433 @@ -646,6 +654,11 @@
1434 (sshsrv (mew-pop-ssh-server case))
1435 (sslp (mew-pop-ssl case))
1436 (sslport (mew-pop-ssl-port case))
1437 + (sslnp (mew-ssl-native-p (mew-pop-ssl case)))
1438 + (starttlsp
1439 + (mew-ssl-starttls-p (mew-pop-ssl case)
1440 + (mew-*-to-string (mew-pop-port case))
1441 + (mew-pop-ssl-port case)))
1442 (proxysrv (mew-pop-proxy-server case))
1443 (proxyport (mew-pop-proxy-port case))
1444 (pnm (mew-pop-info-name case))
1445 @@ -656,25 +669,28 @@
1446 (if (mew-pop-get-process pnm)
1447 (message "Another POP process is running. Try later")
1448 (cond
1449 + (sslnp
1450 + (let ((serv (if starttlsp port sslport)))
1451 + (setq process (mew-pop-open pnm case server serv no-msg starttlsp))))
1452 (sshsrv
1453 (setq sshpro (mew-open-ssh-stream case server port sshsrv))
1454 (when sshpro
1455 (setq sshname (process-name sshpro))
1456 (setq lport (mew-ssh-pnm-to-lport sshname))
1457 (when lport
1458 - (setq process (mew-pop-open pnm "localhost" lport no-msg)))))
1459 + (setq process (mew-pop-open pnm case "localhost" lport no-msg nil)))))
1460 (sslp
1461 - (if (mew-port-equal port sslport) (setq tls mew-tls-pop))
1462 + (when starttlsp (setq tls mew-tls-pop))
1463 (setq sslpro (mew-open-ssl-stream case server sslport tls))
1464 (when sslpro
1465 (setq sslname (process-name sslpro))
1466 (setq lport (mew-ssl-pnm-to-lport sslname))
1467 (when lport
1468 - (setq process (mew-pop-open pnm mew-ssl-localhost lport no-msg)))))
1469 + (setq process (mew-pop-open pnm case mew-ssl-localhost lport no-msg nil)))))
1470 (proxysrv
1471 - (setq process (mew-pop-open pnm proxysrv proxyport no-msg)))
1472 + (setq process (mew-pop-open pnm case proxysrv proxyport no-msg nil)))
1473 (t
1474 - (setq process (mew-pop-open pnm server port no-msg))))
1475 + (setq process (mew-pop-open pnm case server port no-msg nil))))
1476 (if (null process)
1477 (if (eq directive 'exec)
1478 (mew-summary-visible-buffer bnm))
1479 @@ -743,7 +759,13 @@
1480 ;;
1481 (set-process-sentinel process 'mew-pop-sentinel)
1482 (set-process-filter process 'mew-pop-filter)
1483 - (set-process-buffer process buf)))))
1484 + (set-process-buffer process buf)
1485 + (when sslnp
1486 + ;; GnuTLS requires a client-initiated command after the
1487 + ;; session is established or upgraded to use TLS because
1488 + ;; no additional greeting from the server.
1489 + (mew-pop-command-capa process pnm))
1490 + ))))
1491
1492 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1493 ;;;
1494 @@ -960,7 +982,7 @@
1495
1496 ;;; Copyright Notice:
1497
1498 -;; Copyright (C) 1999-2015 Mew developing team.
1499 +;; Copyright (C) 1999-2020 Mew developing team.
1500 ;; All rights reserved.
1501
1502 ;; Redistribution and use in source and binary forms, with or without
1503 diff --git a/mew-smtp.el b/mew-smtp.el
1504 index e3dbbdc..16ae8ef 100644
1505 --- a/mew-smtp.el
1506 +++ b/mew-smtp.el
1507 @@ -6,6 +6,11 @@
1508 ;;; Code:
1509
1510 (require 'mew)
1511 +(autoload 'puny-encode-domain "puny")
1512 +(when (and (fboundp 'gnutls-available-p)
1513 + (gnutls-available-p))
1514 + (require 'gnutls)
1515 + (require 'nsm))
1516
1517 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1518 ;;;
1519 @@ -386,25 +391,237 @@
1520
1521 (defvar mew-smtp-submission-family 'ipv4)
1522
1523 +;;; XXX: (mew-open-network-stream) always returns a list
1524 +;; and is also used for non-SMTP protocols.
1525 +;;; XXX: port must be resolved by using mew-serv-to-port
1526 +;; because some service names are not in /etc/services.
1527 +;; mew-serv-to-port uses mew-port-db.
1528 +(setq mew--advice-tls-parameters-plist nil)
1529 +(defun mew--advice-filter-args-gnutls-negotiate (&rest args)
1530 + (nconc (car args) mew--advice-tls-parameters-plist))
1531 +;;;
1532 +;;; Functions to handle tunneling by an external program. The
1533 +;;; external program must be capable of bidirectional communications
1534 +;;; via stdin and stdout and forward the data stream from/to the final
1535 +;;; destination. TLS and STARTTLS will be handled by GnuTLS.
1536 +;;;
1537 +(defun mew--tun-type (tun-plist)
1538 + (plist-get tun-plist :type))
1539 +(setq mew--advice-tun-command nil)
1540 +(defun mew--advice-tun-command (case host port tun-plist)
1541 + (cond
1542 + ((eq (mew--tun-type tun-plist) 'ssh)
1543 + (format "%s -W %s:%s -oPort=%s %s"
1544 + (mew-ssh-prog case)
1545 + (plist-get tun-plist :host)
1546 + (plist-get tun-plist :port)
1547 + port host))
1548 + (t nil)))
1549 +;; Override function for TLS connection over tunnel.
1550 +(defun mew--advice-override-open-gnutls-stream
1551 + (name buffer host service &optional nowait)
1552 + ;; Must be equivalent to
1553 + ;; (open-gnutls-stream name buffer host service &optional nowait)
1554 + (make-process args
1555 + :command mew--advice-tun-command
1556 + :coding 'utf-8-unix
1557 + :connection-type 'pipe
1558 + :noquery t
1559 + :stderr nil)
1560 + ;; Do gnutls-negotiate here
1561 + )
1562 +;; Override function for PLAIN or STARTTLS connection over tunnel.
1563 +(defun mew--advice-override-make-network-process (&rest args)
1564 + ;; PLAIN: make-network-process
1565 + ;; STARTTLS: make-network-process -> gnutls-negotiate
1566 + (make-process args
1567 + :command mew--advice-tun-command
1568 + :coding 'utf-8-unix
1569 + :connection-type 'pipe
1570 + :noquery t
1571 + :stderr nil))
1572 +;;;
1573 +;;; XXX: This conditional can be removed safely.
1574 (if (fboundp 'make-network-process)
1575 - (defun mew-open-network-stream (name buf server port)
1576 - (let (family nowait pro)
1577 - (when mew-inherit-submission
1578 + (defun mew-open-network-stream (name buf server port proto sslnp
1579 + starttlsp case &optional tun-plist)
1580 + (let* ((tun-type (mew--tun-type tun-plist))
1581 + (mew--advice-tun-command (mew--advice-tun-command
1582 + case server port tun-plist))
1583 + (status-msg (format "Opening a %s connection %s%s%s..."
1584 + (if sslnp "TLS" "TCP")
1585 + (if sslnp "(GnuTLS" "")
1586 + (if sslnp
1587 + (if starttlsp ", STARTTLS)" ")")
1588 + "")
1589 + (if (eq tun-type 'ssh) " over SSH"
1590 + "")))
1591 + family nowait pro tlsparams)
1592 + ;; SMTP-specific
1593 + (when (and (eq proto 'smtp) mew-inherit-submission)
1594 (setq family mew-smtp-submission-family)
1595 (setq nowait t))
1596 - (when (and (stringp port) (string-match "^/" port))
1597 + ;; TLS does not work for Unix-domain socket for now.
1598 + (when (and (not sslnp)
1599 + (stringp port) (string-match "^/" port))
1600 (setq family 'local)
1601 (setq server 'local))
1602 - (setq pro (make-network-process :name name :buffer buf
1603 - :host server :service port
1604 - :family family :nowait nowait))
1605 - (if nowait
1606 + (cond
1607 + ;; Both GnuTLS and NSM are mandatory for 'native.
1608 + ((and sslnp (or (not (fboundp 'gnutls-available-p))
1609 + (not (gnutls-available-p))
1610 + (not (fboundp 'gnutls-boot-parameters))
1611 + (not (fboundp 'nsm-level))))
1612 + (setq pro
1613 + (list nil
1614 + :error t
1615 + :status-msg
1616 + (concat status-msg
1617 + "FAILED (GnuTLS or NSM not available)"))))
1618 + ((and sslnp)
1619 + (let ((hostname (puny-encode-domain server))
1620 + ;; Note: on Emacs 26.3 and prior GnuTLS always uses
1621 + ;; the system-wide default path first even if
1622 + ;; trustfiles is specified.
1623 + (trustfiles (mew-ssl-trustfiles case))
1624 + (nsm-noninteractive nil)
1625 + (network-security-level network-security-level))
1626 + (when (eq (mew-ssl-verify-level case) 0)
1627 + ;; Forcibly disable verification.
1628 + (setq network-security-level 'low))
1629 + (setq tlsparams
1630 + (cons 'gnutls-x509pki
1631 + ;; XXX: (gnutls-boot-parameters) returns
1632 + ;; :priority key instead of :priority-string
1633 + ;; while (gnutls-negotiate) accepts
1634 + ;; :priority-string. To handle this odd
1635 + ;; mismatch, create :priority-string in the
1636 + ;; result of (gnutls-boot-parameters) here.
1637 + (let ((boot-params
1638 + (gnutls-boot-parameters
1639 + :type 'gnutls-x509pki
1640 + :keylist (mew-ssl-client-keycert-list case)
1641 + :trustfiles (mew-ssl-trustfiles case)
1642 + :priority-string (mew-ssl-algorithm-priority case)
1643 + :min-prime-bits mew-ssl-min-prime-bits
1644 + ;;
1645 + ;; mew-ssl-verify-error should be nil
1646 + ;; to defer verification to NSM. Note
1647 + ;; that gnutls-verify-error overrides
1648 + ;; verify-error when it is nil.
1649 + ;; Setting gnutls-verify-error to t is
1650 + ;; also discouraged.
1651 + ;;
1652 + :verify-error mew-ssl-verify-error
1653 + :hostname hostname)))
1654 + (plist-put boot-params
1655 + :priority-string
1656 + (plist-get boot-params :priority)))))
1657 + ;; debug output: TLS params
1658 + (funcall (intern (concat "mew-" (symbol-name proto) "-debug"))
1659 + (format "TLS proto=%s, server=%s:%s, starttlsp=%s"
1660 + proto hostname port starttlsp)
1661 + (format "verify-level=%s, network-security-level=%s, nowait=%s, tlsparams=%s"
1662 + (mew-ssl-verify-level case) network-security-level
1663 + nowait
1664 + (apply #'concat (mapcar (lambda (a) (format "%s " a)) tlsparams))))
1665 + (let ((type (if starttlsp 'starttls 'tls)))
1666 + (with-temp-message status-msg
1667 + ;; XXX: (open-network-stream) does not pass tlsparams
1668 + ;; to (gnutls-negotiate) to start STARTTLS. As a
1669 + ;; workaround, add an advice to forcibly append the
1670 + ;; parameters. This should be fixed in
1671 + ;; (open-network-stream).
1672 + (setq mew--advice-tls-parameters-plist (cdr tlsparams))
1673 + (advice-add 'gnutls-negotiate
1674 + :filter-args #'mew--advice-filter-args-gnutls-negotiate)
1675 + ;;
1676 + ;; Override key functions when using a tunnel.
1677 + (cond
1678 + ((and mew--advice-tun-command (eq type 'tls))
1679 + (advice-add 'open-gnutls-stream
1680 + :override #'mew--advice-override-open-gnutls-stream))
1681 + (mew--advice-tun-command
1682 + (advice-add 'make-network-process
1683 + :override #'mew--advice-override-make-network-process)))
1684 + (setq pro (open-network-stream
1685 + name buf server port
1686 + :type type
1687 + :return-list t
1688 + :nowait nowait
1689 + :always-query-capabilities
1690 + (mew-starttls-get-param proto :always-query-capabilities nil)
1691 + :capability-command
1692 + (mew-starttls-get-param proto :capability-command t)
1693 + :end-of-capability
1694 + (mew-starttls-get-param proto :end-of-capability t)
1695 + :end-of-command
1696 + (mew-starttls-get-param proto :end-of-command t)
1697 + :success
1698 + (mew-starttls-get-param proto :success t)
1699 + :starttls-function
1700 + (mew-starttls-get-param proto :starttls-function nil)))
1701 + (cond
1702 + ((and mew--advice-tun-command (eq type 'tls))
1703 + (advice-remove 'open-gnutls-stream
1704 + #'mew--advice-override-open-gnutls-stream))
1705 + (mew--advice-tun-command
1706 + (advice-remove 'make-network-process
1707 + #'mew--advice-override-make-network-process)))
1708 + (advice-remove 'gnutls-negotiate
1709 + #'mew--advice-filter-args-gnutls-negotiate)
1710 + ;;
1711 + ;; When a validation error occurs, (car pro) will be nil.
1712 + ;;
1713 + (let ((plainp (eq 'plain (plist-get (cdr pro) :type)))
1714 + (openp (and (car pro)
1715 + (eq 'open (process-status (car pro)))))
1716 + ;; Falling back to a plain connection is allowed
1717 + ;; only when verify-level < 2.
1718 + (needtlsp (and starttlsp
1719 + (> (mew-ssl-verify-level case) 1))))
1720 + (cond
1721 + ((not openp)
1722 + (let ((msg (plist-get (cdr pro) :error)))
1723 + (setq pro (list nil
1724 + :error t
1725 + :status-msg
1726 + (concat status-msg "FAILED: " msg)))))
1727 + ((and plainp needtlsp)
1728 + (delete-process (car pro))
1729 + (setq pro (list nil
1730 + :error t
1731 + :status-msg
1732 + (concat status-msg "FAILED"))))
1733 + (t
1734 + (setq pro (list
1735 + (car pro)
1736 + :error nil)))))))))
1737 + (t
1738 + (with-temp-message status-msg
1739 + (let ((params (list :name name :buffer buf
1740 + :service port :family family
1741 + :nowait nowait))
1742 + ;; :host will be ignored when family is 'local.
1743 + (host (if (not (eq family 'local))
1744 + (list :host server))))
1745 + (setq pro (list
1746 + (apply #'make-network-process (nconc params host))
1747 + :greeting nil
1748 + :capabilities nil
1749 + :type 'plain
1750 + :error nil))))))
1751 + (if (and (eq proto 'smtp) nowait)
1752 (run-at-time mew-smtp-submission-timeout nil 'mew-smtp-submission-timeout pro))
1753 + (when (plist-get (cdr pro) :error)
1754 + (message (plist-get (cdr pro) :status-msg)))
1755 pro))
1756 - (defalias 'mew-open-network-stream 'open-network-stream))
1757 + (defun mew-open-network-stream (name buf server port proto sslnp starttlsp case)
1758 + (open-network-stream name buf server port :return-list t)))
1759
1760 -(defun mew-smtp-open (pnm server port)
1761 +(defun mew-smtp-open (pnm case server port starttlsp)
1762 (let ((sprt (mew-*-to-port port))
1763 + (sslnp (mew-ssl-native-p (mew-smtp-ssl case)))
1764 pro tm)
1765 ;; xxx some OSes do not define "submission", sigh.
1766 (when (and (stringp sprt) (string= sprt "submission"))
1767 @@ -413,7 +630,15 @@
1768 (progn
1769 (setq tm (run-at-time mew-smtp-timeout-time nil 'mew-smtp-timeout))
1770 (message "Connecting to the SMTP server...")
1771 - (setq pro (mew-open-network-stream pnm nil server sprt))
1772 + (setq pro (mew-open-network-stream pnm nil server sprt
1773 + 'smtp sslnp starttlsp case))
1774 + (when (and sslnp starttlsp)
1775 + (mew-smtp-debug "*GREETING*"
1776 + (plist-get (cdr pro) :greeting))
1777 + (mew-smtp-debug "*CAPABILITIES*"
1778 + (plist-get (cdr pro) :capabilities)))
1779 + (setq pro (car pro))
1780 + (when (not (processp pro)) (signal 'quit nil))
1781 (mew-process-silent-exit pro)
1782 (mew-set-process-cs pro mew-cs-text-for-net mew-cs-text-for-net)
1783 (message "Connecting to the SMTP server...done"))
1784 @@ -427,7 +652,11 @@
1785 pro))
1786
1787 (defun mew-smtp-timeout ()
1788 - (signal 'quit nil))
1789 + ;; Do not timeout if the NSM query pane is active.
1790 + (unless (get-buffer "*Network Security Manager*")
1791 + (message "SMTP connection timed out (%d seconds)"
1792 + mew-smtp-timeout-time)
1793 + (signal 'quit nil)))
1794
1795 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1796 ;;;
1797 @@ -442,51 +671,64 @@
1798 (sshsrv (mew-smtp-ssh-server case))
1799 (sslp (mew-smtp-ssl case))
1800 (sslport (mew-*-to-string (mew-smtp-ssl-port case)))
1801 + (sslnp (mew-ssl-native-p (mew-smtp-ssl case)))
1802 + (starttlsp
1803 + (mew-ssl-starttls-p (mew-smtp-ssl case)
1804 + (mew-*-to-string (mew-smtp-port case))
1805 + (mew-smtp-ssl-port case)))
1806 mew-inherit-submission
1807 process sshname sshpro sslname sslpro lport tlsp tls fallback)
1808 - (when (and sslp (mew-port-equal port sslport))
1809 + (cond
1810 + ((and (not sslnp) sslp starttlsp)
1811 (setq tlsp t)
1812 ;; let stunnel know that a wrapper protocol is SMTP
1813 - (setq tls mew-tls-smtp))
1814 + (setq tls mew-tls-smtp)))
1815 ;; a fallback: "submission" -> "smtp"
1816 ;; mew-smtp-port is "smtp" and mew-use-submission is t on Emacs 22
1817 - (when (and (or (not sslp) tlsp)
1818 + (when (and (or (not sslp) starttlsp tlsp)
1819 (not fallbacked)
1820 mew-use-submission
1821 (fboundp 'make-network-process) ;; Emacs 22 or later
1822 (mew-port-equal port "smtp"))
1823 (setq port "submission")
1824 (setq fallback t)
1825 - (unless tlsp
1826 + (when (and sslp (not sslnp) (not tlsp))
1827 ;; TLS uses stunnel. So, we should not use non-blocking connect.
1828 ;; Timeout should be carried out by stunnel.
1829 (setq mew-inherit-submission t))
1830 - (if (mew-port-equal sslport "smtp") (setq sslport "submission")))
1831 + (if (mew-port-equal sslport "smtp")
1832 + (setq sslport "submission")))
1833 (cond
1834 + (sslnp
1835 + (let ((serv (if starttlsp port sslport)))
1836 + (setq process (mew-smtp-open pnm case server serv starttlsp))))
1837 (sshsrv
1838 (setq sshpro (mew-open-ssh-stream case server port sshsrv))
1839 (when sshpro
1840 (setq sshname (process-name sshpro))
1841 (setq lport (mew-ssh-pnm-to-lport sshname))
1842 (when lport
1843 - (setq process (mew-smtp-open pnm "localhost" lport)))))
1844 + (setq process (mew-smtp-open pnm case "localhost" lport nil)))))
1845 (sslp
1846 (setq sslpro (mew-open-ssl-stream case server sslport tls))
1847 (when sslpro
1848 (setq sslname (process-name sslpro))
1849 (setq lport (mew-ssl-pnm-to-lport sslname))
1850 (when lport
1851 - (setq process (mew-smtp-open pnm mew-ssl-localhost lport)))))
1852 + (setq process (mew-smtp-open pnm case mew-ssl-localhost lport nil)))))
1853 (t
1854 - (setq process (mew-smtp-open pnm server port))))
1855 + (setq process (mew-smtp-open pnm case server port nil))))
1856 (if (null process)
1857 (cond
1858 ((and sshsrv (null sshpro))
1859 (message "Cannot create to the SSH connection"))
1860 + (sslnp
1861 + (message "Cannot open an SSL/TLS (GnuTLS) connection"))
1862 ((and sslp (null sslpro))
1863 (message "Cannot create to the SSL/TLS connection"))
1864 (t
1865 - (if (and (or (not sslp) tlsp)
1866 + (if (and (not (eq server 'local))
1867 + (or (not sslp) tlsp)
1868 (not fallbacked)
1869 mew-use-submission
1870 (fboundp 'make-network-process)
1871 @@ -520,7 +762,15 @@
1872 (set-process-buffer process nil)
1873 (set-process-sentinel process 'mew-smtp-sentinel)
1874 (set-process-filter process 'mew-smtp-filter)
1875 - (message "Sending in background..."))))
1876 + (message "Sending in background...")
1877 + ;;
1878 + (when sslnp
1879 + ;; GnuTLS requires a client-initiated command after the
1880 + ;; session is established or upgraded to use TLS because
1881 + ;; no additional greeting from the server.
1882 + (mew-smtp-set-status pnm "ehlo")
1883 + (mew-smtp-command-ehlo process pnm))
1884 + )))
1885
1886 (defun mew-smtp-flush-queue (case &optional qfld)
1887 (let (msgs)
1888 @@ -762,7 +1012,7 @@
1889
1890 ;;; Copyright Notice:
1891
1892 -;; Copyright (C) 1999-2015 Mew developing team.
1893 +;; Copyright (C) 1999-2020 Mew developing team.
1894 ;; All rights reserved.
1895
1896 ;; Redistribution and use in source and binary forms, with or without
1897 diff --git a/mew-ssl.el b/mew-ssl.el
1898 index 608ab79..e9c1c6a 100644
1899 --- a/mew-ssl.el
1900 +++ b/mew-ssl.el
1901 @@ -7,6 +7,81 @@
1902
1903 (require 'mew)
1904
1905 +(defun mew-ssl-native-p (type)
1906 + "Return if the type is native or not"
1907 + (or (eq type 'native)
1908 + (and (eq type t) (eq mew-ssl-default 'native))))
1909 +(defun mew-ssl-starttls-p (type port sslport)
1910 + "Return if STARTTLS should be used or not"
1911 + (and type (mew-port-equal port sslport)))
1912 +(defvar mew-ssl-min-prime-bits 2048
1913 + "Default prime bits for GnuTLS connection.")
1914 +(defvar mew-ssl-verify-error nil
1915 + "verify-error parameter passed to GnuTLS. You might want to
1916 +keep this as nil.")
1917 +(defvar mew-ssl-native-starttls-plist
1918 + '(
1919 + ;; RFC 3207
1920 + (smtp . (:capability-command
1921 + (format "EHLO %s\r\n" (mew-smtp-helo-domain case))
1922 + :always-query-capabilities t
1923 + :end-of-command
1924 + (format "^[0-9]+ .*\r?\n")
1925 + :end-of-capability
1926 + (format "^[0-9]+ .*\r?\n")
1927 + :success (format "^2.*\r?\n")
1928 + :starttls-function
1929 + (lambda (capabilities)
1930 + (and (string-match "[ -]STARTTLS" capabilities)
1931 + "STARTTLS\r\n"))))
1932 + ;; RFC 2595
1933 + (imap . (:capability-command
1934 + (format "1 CAPABILITY\r\n")
1935 + :always-query-capabilities t
1936 + :end-of-capability
1937 + (format "\r?\n")
1938 + :end-of-command
1939 + (format "\r?\n")
1940 + :success
1941 + (format "^1 OK ")
1942 + :starttls-function
1943 + (lambda (capabilities)
1944 + (when (string-match-p "STARTTLS" capabilities)
1945 + "1 STARTTLS\r\n"))))
1946 + ;; RFC 2595
1947 + (pop . (:capability-command
1948 + (format "CAPA\r\n")
1949 + :always-query-capabilities nil
1950 + :end-of-capability
1951 + (format "^\\.\r?\n\\|^-ERR")
1952 + :end-of-command
1953 + (format "^\\(-ERR\\|+OK\\).*\r?\n")
1954 + :success
1955 + (format "^\\+OK.*\n")
1956 + :starttls-function
1957 + (lambda (capabilities)
1958 + (and (string-match "\\bSTLS\\b" capabilities)
1959 + "STLS\r\n"))))
1960 + ;; RFC 4642
1961 + (nntp . (:capability-command
1962 + (format "CAPABILITIES\r?\n")
1963 + :always-query-capabilities t
1964 + :end-of-capability
1965 + (format "^\\.\r?\n")
1966 + :end-of-command
1967 + (format "^\\.\r?\n")
1968 + :success
1969 + (format "^2.+ \r?\n")
1970 + :starttls-function
1971 + (lambda (capabilities)
1972 + (when (string-match-p "STARTTLS" capabilities)
1973 + "STARTTLS\r\n"))))
1974 + ))
1975 +(defun mew-starttls-get-param (proto key evalp)
1976 + "Get parameter from mew-ssl-native-starttls-plist"
1977 + (let ((p (plist-get (cdr (assq proto mew-ssl-native-starttls-plist)) key)))
1978 + (if evalp (eval p) p)))
1979 +
1980 (defvar mew-prog-ssl "stunnel")
1981 (defvar mew-ssl-cert-directory "~/.certs"
1982 "The directory where certificates of root servers are stored.
1983 @@ -294,7 +369,7 @@ A local port number can be obtained the process name after ':'. "
1984
1985 ;;; Copyright Notice:
1986
1987 -;; Copyright (C) 2002-2018 Mew developing team.
1988 +;; Copyright (C) 2002-2020 Mew developing team.
1989 ;; All rights reserved.
1990
1991 ;; Redistribution and use in source and binary forms, with or without
1992 diff --git a/mew-vars.el b/mew-vars.el
1993 index 3fa1af3..43104e5 100644
1994 --- a/mew-vars.el
1995 +++ b/mew-vars.el
1996 @@ -578,6 +578,35 @@ is kept for further connections. This must be 't' for IMAP and NNTP."
1997 :group 'mew-net
1998 :type 'boolean)
1999
2000 +(defcustom mew-ssl-default 'tunnel
2001 + "*Default SSL/TLS type when mew-{imap,nntp,pop,smtp}-ssl is 't'."
2002 + :group 'mew-net
2003 + :type '(choice (const :tag "Native (GnuTLS)" native)
2004 + (const :tag "External (stunnel)" tunnel)))
2005 +
2006 +;; XXX: the default value of gnutls-trustfiles can
2007 +;; be different from the compile-time list.
2008 +(defcustom mew-ssl-trustfiles nil
2009 + "List of CA buldle location filenames used by GnuTLS.
2010 +nil - use the default list specified at compile time of the Emacs."
2011 + :group 'mew-net
2012 + :type '(choice (const :tag "System Default" nil)
2013 + (repeat string)))
2014 +
2015 +(defcustom mew-ssl-algorithm-priority nil
2016 + "TLS priority string used by GnuTLS.
2017 +nil - use the default specified by Emacs Network Security Manager."
2018 + :group 'mew-net
2019 + :type '(choice (const :tag "System Default" nil)
2020 + (string :tag "Priority string")))
2021 +
2022 +(defcustom mew-ssl-client-keycert-list nil
2023 + "The client-side certificate used for TLS connection.
2024 +'((\"keyfile\" \"certfile\")) - A list of key/cert pairs."
2025 + :group 'mew-net
2026 + :type '(choice (const :tag "None" nil)
2027 + (repeat string)))
2028 +
2029 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2030 ;;;
2031 ;;; SMTP
2032 @@ -601,11 +630,19 @@ server, set an appropriate value."
2033 (string :tag "Ssh server")))
2034
2035 (defcustom mew-smtp-ssl nil
2036 - "*If non-nil, SMTP connections are made over SSL/TLS."
2037 + "*If non-nil, SMTP connections are made over SSL/TLS.
2038 +native - Use GnuTLS (this requires Emacs compiled with GnuTLS
2039 + library). When mew-smtp-ssl-port is equal to
2040 + mew-smtp-port, a plain connection will be opened and
2041 + upgraded by STARTTLS.
2042 +tunnel - Use an external program to establish a TLS tunnel.
2043 + stunnel(1) utility is used by default."
2044 :group 'mew-smtp
2045 - :type 'boolean)
2046 + :type '(choice (const :tag "No TLS/SSL" nil)
2047 + (const :tag "Native (GnuTLS)" native)
2048 + (const :tag "External (stunnel)" tunnel)))
2049
2050 -(defcustom mew-smtp-ssl-port 465 ;; no universal consensus
2051 +(defcustom mew-smtp-ssl-port 465 ;; RFC 8314
2052 "*The port for SMTP over SSL/TLS. Set this to \"smtp\" if you
2053 want to use TLS."
2054 :group 'mew-smtp
2055 @@ -712,9 +749,17 @@ server, set an appropriate value."
2056 :type '(choice string (const nil)))
2057
2058 (defcustom mew-pop-ssl nil
2059 - "*If non-nil, POP connections are made over SSL/TLS."
2060 + "*If non-nil, POP connections are made over SSL/TLS.
2061 +native - Use GnuTLS (this requires Emacs compiled with GnuTLS
2062 + library). When mew-pop-ssl-port is equal to
2063 + mew-pop-port, a plain connection will be opened and
2064 + upgraded by STARTTLS.
2065 +tunnel - Use an external program to establish a TLS tunnel.
2066 + stunnel(1) utility is used by default."
2067 :group 'mew-pop
2068 - :type 'boolean)
2069 + :type '(choice (const :tag "No TLS/SSL" nil)
2070 + (const :tag "Native (GnuTLS)" native)
2071 + (const :tag "External (stunnel)" tunnel)))
2072
2073 (defcustom mew-pop-ssl-port "pop3s"
2074 "*The port for POP over SSL/TLS."
2075 @@ -805,9 +850,17 @@ server, set an appropriate value."
2076 :type '(choice string (const nil)))
2077
2078 (defcustom mew-imap-ssl nil
2079 - "*If non-nil, IMAP connections are made over SSL/TLS."
2080 + "*If non-nil, IMAP connections are made over SSL/TLS.
2081 +native - Use GnuTLS (this requires Emacs compiled with GnuTLS
2082 + library). When mew-imap-ssl-port is equal to
2083 + mew-imap-port, a plain connection will be opened and
2084 + upgraded by STARTTLS.
2085 +tunnel - Use an external program to establish a TLS tunnel.
2086 + stunnel(1) utility is used by default."
2087 :group 'mew-imap
2088 - :type 'boolean)
2089 + :type '(choice (const :tag "No TLS/SSL" nil)
2090 + (const :tag "Native (GnuTLS)" native)
2091 + (const :tag "External (stunnel)" tunnel)))
2092
2093 (defcustom mew-imap-ssl-port "imaps"
2094 "*The port for IMAP over SSL/TLS."
2095 @@ -922,9 +975,17 @@ server, set an appropriate value."
2096 :type '(choice string (const nil)))
2097
2098 (defcustom mew-nntp-ssl nil
2099 - "*If non-nil, NNTP connections are made over SSL/TLS."
2100 + "*If non-nil, NNTP connections are made over SSL/TLS.
2101 +native - Use GnuTLS (this requires Emacs compiled with GnuTLS
2102 + library). When mew-nntp-ssl-port is equal to
2103 + mew-nntp-port, a plain connection will be opened and
2104 + upgraded by STARTTLS.
2105 +tunnel - Use an external program to establish a TLS tunnel.
2106 + stunnel(1) utility is used by default."
2107 :group 'mew-nntp
2108 - :type 'boolean)
2109 + :type '(choice (const :tag "No TLS/SSL" nil)
2110 + (const :tag "Native (GnuTLS)" native)
2111 + (const :tag "External (stunnel)" tunnel)))
2112
2113 (defcustom mew-nntp-ssl-port "nntps"
2114 "*The port for NNTP over SSL/TLS."
2115 @@ -1674,6 +1735,13 @@ created (if the feature is provided)."
2116 :group 'mew-privacy
2117 :type 'boolean)
2118
2119 +(defcustom mew-master-passwd-type 'master
2120 + "*Type of the password manager when mew-use-master-passwd is non-nil."
2121 + :group 'mew-privacy
2122 + :type '(choice
2123 + (const :tag "Master Password" 'master)
2124 + (const :tag "auth-source" 'auth-source)))
2125 +
2126 (defcustom mew-use-8bit nil
2127 "*If non-nil, the 8bit-clean charset mechanism is used for 8bit
2128 charsets, such as ISO-8859-1, in Draft mode. If nil, an appropriate
2129 diff --git a/mew-vars2.el b/mew-vars2.el
2130 index c7d629e..ddb3d12 100644
2131 --- a/mew-vars2.el
2132 +++ b/mew-vars2.el
2133 @@ -940,7 +940,8 @@ imap-proxy-server, imap-proxy-port,
2134 nntp-server, nntp-port, nntp-ssh-server, nntp-ssl, nntp-ssl-port,
2135 nntp-user, nntp-size, nntp-header-only,
2136 nntp-msgid-user, nntp-msgid-domain,
2137 -ssl-cert-directory, ssl-verify-level,
2138 +ssl-cert-directory, ssl-verify-level, ssl-algorithm-priority,
2139 +ssl-client-keycert-list, ssl-trustfiles,
2140 inbox-folder, queue-folder, postq-folder,
2141 mailbox-type, mbox-command, mbox-command-arg,
2142 signature-file, content-type, refile-guess-alist,